Skip to content

Commit 9f46857

Browse files
committed
Revert "ThreadedGzip classes cannot prevent a program from exiting anymore."
This reverts commit 050fb00.
1 parent c9fdb90 commit 9f46857

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

CHANGELOG.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ Changelog
77
.. This document is user facing. Please word the changes in such a way
88
.. that users understand how the changes affect the new version.
99
10-
version 0.5.1
11-
-----------------
12-
+ Fix a bug where ``gzip_ng_threaded.open`` could
13-
cause a hang when the program exited and the program was not used with a
14-
context manager.
15-
1610
version 0.5.0
1711
-----------------
1812
+ Wheels are now build for MacOS arm64 architectures.

src/zlib_ng/gzip_ng_threaded.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ def __init__(self, filename, queue_size=2, block_size=1024 * 1024):
9898
self.exception = None
9999
self.buffer = io.BytesIO()
100100
self.block_size = block_size
101-
# Using a daemon thread prevents programs freezing on error.
102-
self.worker = threading.Thread(target=self._decompress, daemon=True)
101+
self.worker = threading.Thread(target=self._decompress)
103102
self._closed = False
104103
self.running = True
105104
self.worker.start()
@@ -232,18 +231,17 @@ def __init__(self,
232231
queue.Queue(queue_size) for _ in range(threads)]
233232
self.output_queues: List[queue.Queue[Tuple[bytes, int, int]]] = [
234233
queue.Queue(queue_size) for _ in range(threads)]
235-
# Using daemon threads prevents a program freezing on error.
236-
self.output_worker = threading.Thread(target=self._write, daemon=True)
234+
self.output_worker = threading.Thread(target=self._write)
237235
self.compression_workers = [
238-
threading.Thread(target=self._compress, args=(i,), daemon=True)
236+
threading.Thread(target=self._compress, args=(i,))
239237
for i in range(threads)
240238
]
241239
elif threads == 1:
242240
self.input_queues = [queue.Queue(queue_size)]
243241
self.output_queues = []
244242
self.compression_workers = []
245243
self.output_worker = threading.Thread(
246-
target=self._compress_and_write, daemon=True)
244+
target=self._compress_and_write)
247245
else:
248246
raise ValueError(f"threads should be at least 1, got {threads}")
249247
self.threads = threads

0 commit comments

Comments
 (0)