stream2py 1.0.47__tar.gz → 1.0.48__tar.gz
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.
- {stream2py-1.0.47 → stream2py-1.0.48}/PKG-INFO +1 -1
- {stream2py-1.0.47 → stream2py-1.0.48}/pyproject.toml +1 -1
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/buffer_reader.py +16 -3
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/tests/test_buffer_reader_blocking.py +13 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/.gitattributes +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/.github/workflows/ci.yml +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/.gitignore +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/ISSUE_ANALYSIS.md +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/ISSUE_COMMENTS.md +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/LICENSE +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/PR_DESCRIPTION.md +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/README.md +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/README.rst +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/RESOLVED_ISSUES.md +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/docsrc/.gitignore +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/docsrc/Makefile +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/docsrc/conf.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/docsrc/index.rst +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/docsrc/make.bat +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/buffer_reader.rst +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/protocols.rst +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/simply.rst +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/source_reader.rst +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/sources/http.rst +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/sources.rst +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/stream_buffer.rst +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/stream_source.rst +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/tests/test_buffer_reader.rst +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/tests/test_lock_sorted_deque.rst +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/tests/test_source_reader.rst +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/tests/test_stream_buffer.rst +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/tests/test_stream_source.rst +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/tests/test_util.rst +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/tests/utils_for_testing.rst +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/util.rst +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/utility/locked_sorted_deque.rst +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/utility/reader_writer_lock.rst +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/utility/sorted_collection.rst +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/utility/sorted_deque.rst +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/utility/typing_hints.rst +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py.rst +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/docsrc/table_of_contents.rst +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/pack.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/__init__.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/examples/source_reader.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/examples/stream_source.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/exceptions.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/protocols.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/simply.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/source_reader.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/sources/__init__.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/sources/http.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/stream_buffer.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/stream_source.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/tests/__init__.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/tests/test_buffer_reader.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/tests/test_buffer_reader_stopiteration.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/tests/test_lock_sorted_deque.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/tests/test_quick_source_reader.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/tests/test_reader_without_context.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/tests/test_source_reader.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/tests/test_stream_buffer.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/tests/test_stream_source.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/tests/test_util.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/tests/test_zz_range_join.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/tests/utils_for_testing.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/util.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/utility/__init__.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/utility/locked_sorted_deque.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/utility/reader_writer_lock.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/utility/sorted_collection.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/utility/sorted_deque.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/stream2py/utility/typing_hints.py +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/things_you_can_do.md +0 -0
- {stream2py-1.0.47 → stream2py-1.0.48}/use_cases.md +0 -0
|
@@ -90,6 +90,8 @@ class BufferReader:
|
|
|
90
90
|
source_reader_info: dict,
|
|
91
91
|
stop_event: threading.Event,
|
|
92
92
|
*,
|
|
93
|
+
blocking=False,
|
|
94
|
+
timeout=None,
|
|
93
95
|
read_size=1,
|
|
94
96
|
peek=False,
|
|
95
97
|
strict_n=False,
|
|
@@ -106,6 +108,9 @@ class BufferReader:
|
|
|
106
108
|
:param buffer:
|
|
107
109
|
:param source_reader_info:
|
|
108
110
|
:param stop_event: threading.Event for source read loop
|
|
111
|
+
:param blocking: if True, by default ``read`` waits for the next item when
|
|
112
|
+
none is available yet (see ``read``). Iteration is unaffected.
|
|
113
|
+
:param timeout: default ``timeout`` of blocking reads (``None``: no limit)
|
|
109
114
|
:param read_size: number of items to return by default when reading.
|
|
110
115
|
Is also used as the "chunk size" when iterating.
|
|
111
116
|
:param peek: if True, by default, last_item cursor will not be updated during a
|
|
@@ -130,6 +135,8 @@ class BufferReader:
|
|
|
130
135
|
self.peek = peek
|
|
131
136
|
self.ignore_no_item_found = ignore_no_item_found
|
|
132
137
|
self.strict_n = strict_n
|
|
138
|
+
self.blocking = blocking
|
|
139
|
+
self.timeout = timeout
|
|
133
140
|
# _read_kwargs will be used as the defaults of the read method as well as
|
|
134
141
|
# the kwargs of the __next__ method (with ignore_no_item_found=True forced)
|
|
135
142
|
self._read_kwargs = dict(
|
|
@@ -388,7 +395,7 @@ class BufferReader:
|
|
|
388
395
|
peek=None,
|
|
389
396
|
ignore_no_item_found=None,
|
|
390
397
|
strict_n=None,
|
|
391
|
-
blocking=
|
|
398
|
+
blocking=None,
|
|
392
399
|
timeout=None,
|
|
393
400
|
):
|
|
394
401
|
"""Finds an item with a key greater than the last returned item.
|
|
@@ -402,8 +409,10 @@ class BufferReader:
|
|
|
402
409
|
:param ignore_no_item_found: if True, return None when no next item
|
|
403
410
|
instead of raising exception
|
|
404
411
|
:param strict_n: if True, raise ValueError if n items are not available
|
|
405
|
-
:param blocking: if True, wait to return next item if not yet available
|
|
406
|
-
|
|
412
|
+
:param blocking: if True, wait to return next item if not yet available.
|
|
413
|
+
Defaults to the reader's ``blocking`` (False unless set at construction).
|
|
414
|
+
:param timeout: only used when ``blocking`` is True. Defaults to the reader's
|
|
415
|
+
``timeout``. Maximum number of seconds
|
|
407
416
|
to wait; ``None`` (default) waits until an item is available or the stream
|
|
408
417
|
stops. When it runs out, returns None (as when the stream stops).
|
|
409
418
|
:return: next item or list of next items if n > 1
|
|
@@ -424,6 +433,10 @@ class BufferReader:
|
|
|
424
433
|
# )
|
|
425
434
|
# strict_n = strict_n or self._read_kwargs['strict_n']
|
|
426
435
|
|
|
436
|
+
if blocking is None:
|
|
437
|
+
blocking = self.blocking
|
|
438
|
+
if timeout is None:
|
|
439
|
+
timeout = self.timeout
|
|
427
440
|
if blocking is True:
|
|
428
441
|
deadline = None if timeout is None else time.monotonic() + timeout
|
|
429
442
|
while True:
|
|
@@ -88,3 +88,16 @@ def test_buffer_reader_blocking_timeout():
|
|
|
88
88
|
assert reader.read(blocking=True, timeout=0.3) is None
|
|
89
89
|
elapsed = time.monotonic() - start
|
|
90
90
|
assert 0.3 <= elapsed < 2
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def test_buffer_reader_blocking_default_from_mk_reader():
|
|
94
|
+
"""``mk_reader(blocking=True, timeout=...)`` makes reads block by default."""
|
|
95
|
+
with StreamBuffer(SimpleSourceReader(range(3)), maxlen=100) as buffer:
|
|
96
|
+
reader = buffer.mk_reader(blocking=True, timeout=0.3)
|
|
97
|
+
assert wait_until(lambda: len(buffer.source_buffer) >= 3)
|
|
98
|
+
assert reader.read(n=3) is not None
|
|
99
|
+
start = time.monotonic()
|
|
100
|
+
assert reader.read() is None # waited ~timeout instead of raising
|
|
101
|
+
assert 0.3 <= time.monotonic() - start < 2
|
|
102
|
+
# explicit blocking=False overrides the default
|
|
103
|
+
assert reader.read(blocking=False, ignore_no_item_found=True) is None
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/tests/test_buffer_reader.rst
RENAMED
|
File without changes
|
{stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/tests/test_lock_sorted_deque.rst
RENAMED
|
File without changes
|
{stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/tests/test_source_reader.rst
RENAMED
|
File without changes
|
{stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/tests/test_stream_buffer.rst
RENAMED
|
File without changes
|
{stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/tests/test_stream_source.rst
RENAMED
|
File without changes
|
|
File without changes
|
{stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/tests/utils_for_testing.rst
RENAMED
|
File without changes
|
|
File without changes
|
{stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/utility/locked_sorted_deque.rst
RENAMED
|
File without changes
|
{stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/utility/reader_writer_lock.rst
RENAMED
|
File without changes
|
{stream2py-1.0.47 → stream2py-1.0.48}/docsrc/module_docs/stream2py/utility/sorted_collection.rst
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|