SQLite Forum

How to circumvent "apsw.BusyError: BusyError: database is locked"?
SQLITE_BUSY is SQLite's way of telling you that you are in a deadlock. You need to change your application to avoid the deadlock.

Since you don't divulge how you faithfully reproduce the deadlock, remedies cannot be suggested. Other than maybe using BEGIN IMMEDIATE so that upgrading transactions from READ to WRITE is avoided.

Look up the Dining Philosophers problem. Nobody gets to eat until one of them lets go of the one fork they already have. No amount of waiting will resolve the issue, which incidentally is the definition of deadlock.