Skip to content

Commit

Permalink
Do not set daemon via kwargs
Browse files Browse the repository at this point in the history
  • Loading branch information
rhpvorderman committed Sep 11, 2024
1 parent c6329c2 commit 033c536
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/zlib_ng/gzip_ng_threaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ def __init__(self, filename, queue_size=2, block_size=1024 * 1024):
self.buffer = io.BytesIO()
self.block_size = block_size
# Using a daemon thread prevents programs freezing on error.
self.worker = threading.Thread(target=self._decompress, daemon=True)
self.worker = threading.Thread(target=self._decompress)
self.worker.daemon = True
self._closed = False
self.running = True
self.worker.start()
Expand Down Expand Up @@ -233,17 +234,20 @@ def __init__(self,
self.output_queues: List[queue.Queue[Tuple[bytes, int, int]]] = [
queue.Queue(queue_size) for _ in range(threads)]
# Using daemon threads prevents a program freezing on error.
self.output_worker = threading.Thread(target=self._write, daemon=True)
self.compression_workers = [
threading.Thread(target=self._compress, args=(i,), daemon=True)
for i in range(threads)
]
self.output_worker = threading.Thread(target=self._write)
self.output_worker.daemon = True
self.compression_workers: List[threading.Thread] = []
for i in range(threads):
worker = threading.Thread(target=self._compress, args=(i,))
worker.daemon = True
self.compression_workers.append(worker)

elif threads == 1:
self.input_queues = [queue.Queue(queue_size)]
self.output_queues = []
self.compression_workers = []
self.output_worker = threading.Thread(
target=self._compress_and_write, daemon=True)
self.output_worker = threading.Thread(target=self._compress_and_write)
self.output_worker.daemon = True
else:
raise ValueError(f"threads should be at least 1, got {threads}")
self.threads = threads
Expand Down

0 comments on commit 033c536

Please sign in to comment.