Enable handling of DB lock collisions
The error is raised by the sqlite driver you are using -- I'd suggest checking the error message contained in the exception if you want to do special handling of this exception. For general suggestions on how to handle sqlite's write-locking, these posts may help:

* https://charlesleifer.com/blog/going-fast-with-sqlite-and-python/
* https://charlesleifer.com/blog/multi-threaded-sqlite-without-the-operationalerrors/

You can set a timeout on the database instance which controls the busy-timeout sqlite uses for retrying to acquire the lock:

* http://docs.peewee-orm.com/en/latest/peewee/api.html#SqliteDatabase

I'd also suggest you familiarize yourself with how sqlite locking works on the sqlite docs website.

Also, in case it wasn't clear, sqlite + peewee already specifies a default 5 second busy timeout (if lock is busy, keep attempting to acquire it) - this is a relative eternity in sqlite terms.
I'm using Peewee with SQLite DBs. Is there a way to either specify behavior in cases of lock collisions, or to programmatically detect whether a lock collision has occurred, as opposed to some other error?

A lock collision seem to result in an `OperationalError`. This is a relatively broad Peewee error (e.g. attempting to use a DB to which a process hasn't connected will cause the same error). As far as I can tell, this means that it's not possible to explicitly handle lock collisions in client code (to, e.g., wait and retry rather than crashing the process). First of all, am I missing some existing approach?

A relatively simple solution would be to create a subclass of `OperationalError` (say, a `LockCollisionError`) to be thrown in the case of a lock collision. This would be backwards-compatible with existing error handling and allow users to choose how to handle lock collisions.

I'm using Python's asyncio library. So even more useful would be a coroutine allowing client code to wait on the availability of a lock. I realize that this is a more significant project, though.

Thanks in advance!
-Leo Selker