Skip to content

Commit

Permalink
Merge pull request #261 from lzaoral/worker-dead-thread-deadlock
Browse files Browse the repository at this point in the history
worker: fix deadlock when the `LoggingThread` is not running
  • Loading branch information
rohanpm authored May 2, 2024
2 parents d4b1c22 + 66caaab commit b3720e0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions kobo/worker/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ def run(self):

def write(self, data):
"""Add data to the queue and set the event for sending queue content."""
# Discard the data if the thread is not running to prevent deadlock
# when the queue is full.
if not self.is_alive():
return

if threading.get_ident() != self.ident:
self._queue.put(data)
self._event.set()
Expand Down

0 comments on commit b3720e0

Please sign in to comment.