Skip to content

Commit

Permalink
Additional fixes to ensure we don't block forever during shutdown.
Browse files Browse the repository at this point in the history
Refs #2877
  • Loading branch information
coleifer committed Apr 23, 2024
1 parent 1cca5dc commit 519a84e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions playhouse/sqliteq.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,18 @@ def stop(self):
with self._qlock:
if self._is_stopped:
return False

self._write_queue.put((SHUTDOWN, None))
self._writer.join()

# Empty queue of any remaining tasks.
while not self._write_queue.empty():
op, obj = self._write_queue.get()
if op == PAUSE or op == UNPAUSE:
obj.set()
elif op == QUERY:
obj.set_result(None, ShutdownException())

self._is_stopped = True
return True

Expand Down

0 comments on commit 519a84e

Please sign in to comment.