Skip to content

Commit 6a6ff69

Browse files
committed
Closeoff running threads
1 parent 85ec793 commit 6a6ff69

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/isal/igzip_threaded.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import io
22
import queue
33
import threading
4-
from time import perf_counter_ns
54

65
from . import igzip
76

@@ -44,7 +43,11 @@ def _decompress(self):
4443
return
4544
if not data:
4645
return
47-
block_queue.put(data)
46+
while self.running:
47+
try:
48+
block_queue.put(data, timeout=0.05)
49+
except queue.Full:
50+
pass
4851

4952
def readinto(self, b):
5053
result = self.buffer.readinto(b)
@@ -61,6 +64,7 @@ def readinto(self, b):
6164
return 0
6265
self.buffer = io.BytesIO(data_from_queue)
6366
result = self.buffer.readinto(b)
67+
self.pos += result
6468
return result
6569

6670
def readable(self) -> bool:
@@ -73,4 +77,6 @@ def tell(self) -> int:
7377
return self.pos
7478

7579
def close(self) -> None:
80+
self.running = False
81+
self.worker.join()
7682
self.fileobj.close()

0 commit comments

Comments
 (0)