nominal-streaming 0.7.7__cp310-abi3-musllinux_1_2_aarch64.whl → 0.7.12__cp310-abi3-musllinux_1_2_aarch64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nominal_streaming/_nominal_streaming.abi3.so +0 -0
- nominal_streaming/nominal_dataset_stream.py +26 -13
- {nominal_streaming-0.7.7.dist-info → nominal_streaming-0.7.12.dist-info}/METADATA +1 -1
- nominal_streaming-0.7.12.dist-info/RECORD +9 -0
- nominal_streaming.libs/libgcc_s-0bf60adc.so.1 +0 -0
- nominal_streaming-0.7.7.dist-info/RECORD +0 -9
- nominal_streaming.libs/libgcc_s-39080030.so.1 +0 -0
- {nominal_streaming-0.7.7.dist-info → nominal_streaming-0.7.12.dist-info}/WHEEL +0 -0
|
Binary file
|
|
@@ -34,6 +34,7 @@ import datetime
|
|
|
34
34
|
import logging
|
|
35
35
|
import pathlib
|
|
36
36
|
import signal
|
|
37
|
+
import threading
|
|
37
38
|
from types import TracebackType
|
|
38
39
|
from typing import Mapping, Sequence, Type
|
|
39
40
|
|
|
@@ -78,6 +79,7 @@ class NominalDatasetStream:
|
|
|
78
79
|
self._opts = opts
|
|
79
80
|
self._impl = PyNominalDatasetStream(self._opts)
|
|
80
81
|
self._old_sigint = None
|
|
82
|
+
self._opened = False
|
|
81
83
|
|
|
82
84
|
@classmethod
|
|
83
85
|
def create(
|
|
@@ -181,25 +183,35 @@ class NominalDatasetStream:
|
|
|
181
183
|
"""Create the stream as a context manager.
|
|
182
184
|
|
|
183
185
|
NOTE: installs a sigint handler to enable more graceful shutdown.
|
|
184
|
-
This is restored upon exit.
|
|
186
|
+
This is restored upon exit. The handler is only installed when
|
|
187
|
+
running in the main thread; in worker threads, the stream still
|
|
188
|
+
functions but Ctrl+C will not trigger graceful cancellation.
|
|
185
189
|
"""
|
|
186
|
-
if self.
|
|
190
|
+
if self._opened:
|
|
187
191
|
raise RuntimeError("Stream already opened!")
|
|
188
192
|
|
|
189
193
|
logger.info("Opening underlying stream")
|
|
190
194
|
self._impl.open()
|
|
195
|
+
self._opened = True
|
|
196
|
+
|
|
197
|
+
if threading.current_thread() is threading.main_thread():
|
|
198
|
+
# Map Ctrl+C → fast cancel; keep handler tiny and re-raise KeyboardInterrupt.
|
|
199
|
+
def _on_sigint(signum, frame): # type: ignore[no-untyped-def]
|
|
200
|
+
logger.debug("Cancelling underlying stream")
|
|
201
|
+
try:
|
|
202
|
+
self._impl.cancel()
|
|
203
|
+
finally:
|
|
204
|
+
raise KeyboardInterrupt
|
|
205
|
+
|
|
206
|
+
logger.info("Installing sigint handler")
|
|
207
|
+
self._old_sigint = signal.getsignal(signal.SIGINT) # type: ignore[assignment]
|
|
208
|
+
signal.signal(signal.SIGINT, _on_sigint)
|
|
209
|
+
else:
|
|
210
|
+
logger.info(
|
|
211
|
+
"Stream opened from worker thread; Ctrl+C will not trigger fast cancellation. "
|
|
212
|
+
"Stream will close gracefully when the context manager exits."
|
|
213
|
+
)
|
|
191
214
|
|
|
192
|
-
# Map Ctrl+C → fast cancel; keep handler tiny and re-raise KeyboardInterrupt.
|
|
193
|
-
def _on_sigint(signum, frame): # type: ignore[no-untyped-def]
|
|
194
|
-
logger.debug("Cancelling underlying stream")
|
|
195
|
-
try:
|
|
196
|
-
self._impl.cancel()
|
|
197
|
-
finally:
|
|
198
|
-
raise KeyboardInterrupt
|
|
199
|
-
|
|
200
|
-
logger.info("Installing sigint handler")
|
|
201
|
-
self._old_sigint = signal.getsignal(signal.SIGINT) # type: ignore[assignment]
|
|
202
|
-
signal.signal(signal.SIGINT, _on_sigint)
|
|
203
215
|
return self
|
|
204
216
|
|
|
205
217
|
def __enter__(self) -> Self:
|
|
@@ -227,6 +239,7 @@ class NominalDatasetStream:
|
|
|
227
239
|
logger.info("Restoring original sigint handler")
|
|
228
240
|
signal.signal(signal.SIGINT, self._old_sigint)
|
|
229
241
|
self._old_sigint = None
|
|
242
|
+
self._opened = False
|
|
230
243
|
|
|
231
244
|
def __exit__(
|
|
232
245
|
self,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
nominal_streaming-0.7.12.dist-info/METADATA,sha256=3eBnTdIuigzCrrQ95lSTguA9FcqFKBMP2J8DoHUKb_A,2815
|
|
2
|
+
nominal_streaming-0.7.12.dist-info/WHEEL,sha256=EYTFw83l-1Egr0yK8_y3A2oK6lLpVyAvyCNXIbM92ys,107
|
|
3
|
+
nominal_streaming.libs/libgcc_s-0bf60adc.so.1,sha256=9fhX5YpiwtHdsiLMLz77Pw9jjIEGriteV7UOUrrwvpk,527681
|
|
4
|
+
nominal_streaming/__init__.py,sha256=7isEI7NFTEnTNEmxjtDgehQQPPRM-ByrH903VBWrulQ,202
|
|
5
|
+
nominal_streaming/_nominal_streaming.abi3.so,sha256=px2fDVEjTHnBLsLm_WdwvQ6xn2gNOHQzARJwKzEAs2c,7736865
|
|
6
|
+
nominal_streaming/_nominal_streaming.pyi,sha256=hZ5TpAFFMZzajSu13yh-klEh81ItvF5C5f_3i0rMfkM,12093
|
|
7
|
+
nominal_streaming/nominal_dataset_stream.py,sha256=egiSbsd6q_yL8ub8Rc6YukPauwEDivICQd1dSTlOfEc,12121
|
|
8
|
+
nominal_streaming/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
+
nominal_streaming-0.7.12.dist-info/RECORD,,
|
|
Binary file
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
nominal_streaming-0.7.7.dist-info/METADATA,sha256=FFVgUr8QBa6CIJORR6G_r9v-cokNL4U40IX5iP7ZHqk,2814
|
|
2
|
-
nominal_streaming-0.7.7.dist-info/WHEEL,sha256=EYTFw83l-1Egr0yK8_y3A2oK6lLpVyAvyCNXIbM92ys,107
|
|
3
|
-
nominal_streaming.libs/libgcc_s-39080030.so.1,sha256=fIO6GHOh8Ft9CR0Geu7wSUb9Xnl122iTtrxQQ9TAkTQ,789673
|
|
4
|
-
nominal_streaming/__init__.py,sha256=7isEI7NFTEnTNEmxjtDgehQQPPRM-ByrH903VBWrulQ,202
|
|
5
|
-
nominal_streaming/_nominal_streaming.abi3.so,sha256=COb2kv29-z3yisfbtHMofFWAtg3nHl7nrfvdPNvaJTw,7867921
|
|
6
|
-
nominal_streaming/_nominal_streaming.pyi,sha256=hZ5TpAFFMZzajSu13yh-klEh81ItvF5C5f_3i0rMfkM,12093
|
|
7
|
-
nominal_streaming/nominal_dataset_stream.py,sha256=0OXLiGDhyT9Q4z0QJlXaV7H3Nd3OWMPi2bjQJKcM5eE,11507
|
|
8
|
-
nominal_streaming/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
-
nominal_streaming-0.7.7.dist-info/RECORD,,
|
|
Binary file
|
|
File without changes
|