There's no way that I know of either using SQL or the C API. Even if there was, some other thread could grab the lock immediately after your test. OTOH, you can create a mutex on the Python side of things (thread.lock), in your application, but the same comments apply.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
From one thread I might execute
c.execute("LOCK TABLE ...")
Is it possible to tell in advance from another thread that a particular table has been locked and what type of lock is held?
There's no way that I know of either using SQL or the C API. Even if there was, some other thread could grab the lock immediately after your test. OTOH, you can create a mutex on the Python side of things (thread.lock), in your application, but the same comments apply.