nominal-streaming 0.7.5__cp310-abi3-musllinux_1_2_armv7l.whl → 0.7.12__cp310-abi3-musllinux_1_2_armv7l.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.
@@ -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._old_sigint is not None:
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,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nominal-streaming
3
- Version: 0.7.5
3
+ Version: 0.7.12
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Classifier: Programming Language :: Rust
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -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=t1NqWma56BePE1J5SCaB3iADsaLxJfncQEOq2axBQRg,106
3
+ nominal_streaming.libs/libgcc_s-262c4f60.so.1,sha256=xPsZgCvL7EO-llmjqc5bm96baehLsO4avBqUhih0xZg,2810501
4
+ nominal_streaming/__init__.py,sha256=7isEI7NFTEnTNEmxjtDgehQQPPRM-ByrH903VBWrulQ,202
5
+ nominal_streaming/_nominal_streaming.abi3.so,sha256=vd8th-166jRBHRrwMnx_VvBfBHsjuyNfvBdRrX9ua0Y,6569257
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,,
@@ -1,9 +0,0 @@
1
- nominal_streaming-0.7.5.dist-info/METADATA,sha256=-VAuBpQmXYwBXhdYcqQ0mBaHzo4JLcBZPClyKl0Sn58,2814
2
- nominal_streaming-0.7.5.dist-info/WHEEL,sha256=t1NqWma56BePE1J5SCaB3iADsaLxJfncQEOq2axBQRg,106
3
- nominal_streaming.libs/libgcc_s-262c4f60.so.1,sha256=xPsZgCvL7EO-llmjqc5bm96baehLsO4avBqUhih0xZg,2810501
4
- nominal_streaming/__init__.py,sha256=7isEI7NFTEnTNEmxjtDgehQQPPRM-ByrH903VBWrulQ,202
5
- nominal_streaming/_nominal_streaming.abi3.so,sha256=v9Vj_HB6Fwfx1c4hgj6IMVFCfs4F34Xo1Af9Jr0QXDk,6630697
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.5.dist-info/RECORD,,