stream2py 1.0.45__tar.gz → 1.0.46__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.45 → stream2py-1.0.46}/PKG-INFO +1 -1
- {stream2py-1.0.45 → stream2py-1.0.46}/pyproject.toml +1 -1
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/tests/test_buffer_reader_blocking.py +3 -3
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/tests/test_buffer_reader_stopiteration.py +4 -11
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/tests/test_reader_without_context.py +3 -5
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/tests/test_stream_buffer.py +6 -3
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/tests/test_stream_source.py +6 -3
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/tests/utils_for_testing.py +15 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/.gitattributes +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/.github/workflows/ci.yml +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/.gitignore +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/ISSUE_ANALYSIS.md +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/ISSUE_COMMENTS.md +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/LICENSE +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/PR_DESCRIPTION.md +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/README.md +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/README.rst +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/RESOLVED_ISSUES.md +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/docsrc/.gitignore +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/docsrc/Makefile +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/docsrc/conf.py +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/docsrc/index.rst +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/docsrc/make.bat +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py/buffer_reader.rst +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py/protocols.rst +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py/simply.rst +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py/source_reader.rst +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py/sources/http.rst +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py/sources.rst +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py/stream_buffer.rst +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py/stream_source.rst +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py/tests/test_buffer_reader.rst +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py/tests/test_lock_sorted_deque.rst +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py/tests/test_source_reader.rst +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py/tests/test_stream_buffer.rst +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py/tests/test_stream_source.rst +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py/tests/test_util.rst +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py/tests/utils_for_testing.rst +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py/util.rst +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py/utility/locked_sorted_deque.rst +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py/utility/reader_writer_lock.rst +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py/utility/sorted_collection.rst +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py/utility/sorted_deque.rst +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py/utility/typing_hints.rst +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py.rst +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/docsrc/table_of_contents.rst +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/pack.py +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/__init__.py +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/buffer_reader.py +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/examples/source_reader.py +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/examples/stream_source.py +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/exceptions.py +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/protocols.py +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/simply.py +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/source_reader.py +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/sources/__init__.py +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/sources/http.py +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/stream_buffer.py +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/stream_source.py +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/tests/__init__.py +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/tests/test_buffer_reader.py +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/tests/test_lock_sorted_deque.py +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/tests/test_quick_source_reader.py +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/tests/test_source_reader.py +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/tests/test_util.py +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/tests/test_zz_range_join.py +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/util.py +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/utility/__init__.py +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/utility/locked_sorted_deque.py +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/utility/reader_writer_lock.py +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/utility/sorted_collection.py +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/utility/sorted_deque.py +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/stream2py/utility/typing_hints.py +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/things_you_can_do.md +0 -0
- {stream2py-1.0.45 → stream2py-1.0.46}/use_cases.md +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import time
|
|
3
3
|
import threading
|
|
4
4
|
from stream2py import StreamBuffer
|
|
5
|
-
from stream2py.tests.utils_for_testing import SimpleSourceReader
|
|
5
|
+
from stream2py.tests.utils_for_testing import SimpleSourceReader, wait_until
|
|
6
6
|
from itertools import count
|
|
7
7
|
|
|
8
8
|
|
|
@@ -15,7 +15,7 @@ def test_buffer_reader_blocking():
|
|
|
15
15
|
reader = buffer.mk_reader()
|
|
16
16
|
|
|
17
17
|
# Wait a moment for some data to be available
|
|
18
|
-
|
|
18
|
+
assert wait_until(lambda: len(buffer.source_buffer) >= 6)
|
|
19
19
|
|
|
20
20
|
# Non-blocking read should return data immediately when available
|
|
21
21
|
result = reader.read(blocking=False, ignore_no_item_found=True)
|
|
@@ -47,7 +47,7 @@ def test_buffer_reader_blocking_stops_on_stop_event():
|
|
|
47
47
|
reader = buffer.mk_reader()
|
|
48
48
|
|
|
49
49
|
# Read all available data
|
|
50
|
-
|
|
50
|
+
assert wait_until(lambda: len(buffer.source_buffer) >= 5)
|
|
51
51
|
while reader.read(blocking=False, ignore_no_item_found=True) is not None:
|
|
52
52
|
pass
|
|
53
53
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Tests for BufferReader StopIteration behavior (Issue #10)"""
|
|
2
2
|
import pytest
|
|
3
3
|
from stream2py import StreamBuffer
|
|
4
|
-
from stream2py.tests.utils_for_testing import SimpleSourceReader
|
|
4
|
+
from stream2py.tests.utils_for_testing import SimpleSourceReader, wait_until
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
def test_next_raises_stopiteration_when_stopped():
|
|
@@ -38,10 +38,7 @@ def test_next_returns_none_when_no_data_but_running():
|
|
|
38
38
|
reader = buffer.mk_reader()
|
|
39
39
|
|
|
40
40
|
# Read all available data quickly
|
|
41
|
-
|
|
42
|
-
deadline = time.time() + 5 # wait for data rather than hope 0.1s is enough on a loaded runner
|
|
43
|
-
while not len(buffer.source_buffer) and time.time() < deadline:
|
|
44
|
-
time.sleep(0.01)
|
|
41
|
+
assert wait_until(lambda: len(buffer.source_buffer) >= 1)
|
|
45
42
|
|
|
46
43
|
# Read until we get None (no more data available yet)
|
|
47
44
|
items = []
|
|
@@ -65,8 +62,7 @@ def test_builtin_next_with_default():
|
|
|
65
62
|
buffer.start()
|
|
66
63
|
reader = buffer.mk_reader()
|
|
67
64
|
|
|
68
|
-
|
|
69
|
-
time.sleep(0.1)
|
|
65
|
+
assert wait_until(lambda: len(buffer.source_buffer) >= 2)
|
|
70
66
|
|
|
71
67
|
# Read items
|
|
72
68
|
item1 = next(reader, 'default')
|
|
@@ -80,8 +76,6 @@ def test_builtin_next_with_default():
|
|
|
80
76
|
|
|
81
77
|
# When stopped and no data, should raise StopIteration
|
|
82
78
|
# and the default should be returned by builtin next()
|
|
83
|
-
time.sleep(0.1)
|
|
84
|
-
|
|
85
79
|
# Consume any remaining data
|
|
86
80
|
while True:
|
|
87
81
|
try:
|
|
@@ -104,8 +98,7 @@ def test_for_loop_stops_correctly():
|
|
|
104
98
|
buffer = StreamBuffer(source, maxlen=100)
|
|
105
99
|
buffer.start()
|
|
106
100
|
|
|
107
|
-
|
|
108
|
-
time.sleep(0.2) # Let all data load
|
|
101
|
+
assert wait_until(lambda: len(buffer.source_buffer) >= 10) # all data loaded
|
|
109
102
|
|
|
110
103
|
buffer.stop() # Stop before iterating
|
|
111
104
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Tests for using readers without context manager (Issue #18)"""
|
|
2
2
|
import pytest
|
|
3
3
|
from stream2py import StreamBuffer
|
|
4
|
-
from stream2py.tests.utils_for_testing import SimpleSourceReader
|
|
4
|
+
from stream2py.tests.utils_for_testing import SimpleSourceReader, wait_until
|
|
5
5
|
from stream2py.exceptions import StreamNotStartedError
|
|
6
6
|
|
|
7
7
|
|
|
@@ -26,8 +26,7 @@ def test_reader_works_without_context_manager():
|
|
|
26
26
|
reader = buffer.mk_reader()
|
|
27
27
|
|
|
28
28
|
# Reading should work fine without context manager
|
|
29
|
-
|
|
30
|
-
time.sleep(0.1) # Let some data accumulate
|
|
29
|
+
assert wait_until(lambda: len(buffer.source_buffer) >= 2) # some data accumulated
|
|
31
30
|
|
|
32
31
|
item = reader.read(ignore_no_item_found=True)
|
|
33
32
|
assert item is not None
|
|
@@ -84,8 +83,7 @@ def test_stream_buffer_with_context():
|
|
|
84
83
|
with StreamBuffer(source, maxlen=100) as buffer:
|
|
85
84
|
reader = buffer.mk_reader()
|
|
86
85
|
|
|
87
|
-
|
|
88
|
-
time.sleep(0.1)
|
|
86
|
+
assert wait_until(lambda: len(buffer.source_buffer) >= 1)
|
|
89
87
|
|
|
90
88
|
item = reader.read(ignore_no_item_found=True)
|
|
91
89
|
assert item is not None
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
from stream2py.tests.utils_for_testing import
|
|
1
|
+
from stream2py.tests.utils_for_testing import (
|
|
2
|
+
TenthSecondCounterStreamSource,
|
|
3
|
+
wait_until,
|
|
4
|
+
)
|
|
2
5
|
from stream2py.stream_buffer import StreamBuffer
|
|
3
6
|
import time
|
|
4
7
|
|
|
@@ -12,7 +15,7 @@ def test_stream_buffer():
|
|
|
12
15
|
sc_reader = (
|
|
13
16
|
sc_buf.mk_reader()
|
|
14
17
|
) # reader must be made after start to have data related to said start
|
|
15
|
-
|
|
18
|
+
assert wait_until(lambda: len(sc_buf.source_buffer) >= 20) # ~2s of data
|
|
16
19
|
assert sc_reader.source_reader_info['bt'] != 0, sc_reader.source_reader_info
|
|
17
20
|
print('data as shown is (timestamp, count) at every tenth of a second')
|
|
18
21
|
while True:
|
|
@@ -87,7 +90,7 @@ def test_stream_buffer():
|
|
|
87
90
|
), 'new readers should now have the same last_item cursor position'
|
|
88
91
|
|
|
89
92
|
# print some data from old and new reader and see they are different
|
|
90
|
-
|
|
93
|
+
assert wait_until(lambda: len(sc_buf.source_buffer) >= 3)
|
|
91
94
|
print('comparing first start reader values to second start')
|
|
92
95
|
while True:
|
|
93
96
|
r22 = sc_reader22.read(n=1, ignore_no_item_found=True)
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
from stream2py.tests.utils_for_testing import
|
|
1
|
+
from stream2py.tests.utils_for_testing import (
|
|
2
|
+
TenthSecondCounterStreamSource,
|
|
3
|
+
wait_until,
|
|
4
|
+
)
|
|
2
5
|
import time
|
|
3
6
|
|
|
4
7
|
|
|
@@ -6,7 +9,7 @@ def test_stream_source():
|
|
|
6
9
|
source = TenthSecondCounterStreamSource() # source
|
|
7
10
|
with source.open_reader() as sc_reader:
|
|
8
11
|
sc_buf = source._stream_buffer
|
|
9
|
-
|
|
12
|
+
assert wait_until(lambda: len(sc_buf.source_buffer) >= 20) # ~2s of data
|
|
10
13
|
assert source.info['bt'] != 0, source.info
|
|
11
14
|
print('data as shown is (timestamp, count) at every tenth of a second')
|
|
12
15
|
while True:
|
|
@@ -85,7 +88,7 @@ def test_stream_source():
|
|
|
85
88
|
), 'new readers should now have the same last_item cursor position'
|
|
86
89
|
|
|
87
90
|
# print some data from old and new reader and see they are different
|
|
88
|
-
|
|
91
|
+
assert wait_until(lambda: len(sc_buf.source_buffer) >= 3)
|
|
89
92
|
print('comparing first start reader values to second start')
|
|
90
93
|
while True:
|
|
91
94
|
r22 = sc_reader22.read(n=1, ignore_no_item_found=True)
|
|
@@ -271,3 +271,18 @@ class TenthSecondCounterStreamSource(StreamSource):
|
|
|
271
271
|
return None
|
|
272
272
|
|
|
273
273
|
key = operator.itemgetter(0) # (timestamp_us, count) -> timestamp_us
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
def wait_until(condition, *, timeout=10.0, interval=0.01):
|
|
277
|
+
"""Poll ``condition()`` until it is truthy or ``timeout`` seconds pass.
|
|
278
|
+
|
|
279
|
+
Use instead of a fixed ``time.sleep`` before asserting on data produced by a
|
|
280
|
+
background thread: a fixed sleep is too short on a loaded (or single-core) runner.
|
|
281
|
+
Returns the final truthiness of ``condition()`` so callers can ``assert`` it.
|
|
282
|
+
"""
|
|
283
|
+
deadline = time.monotonic() + timeout
|
|
284
|
+
while not condition():
|
|
285
|
+
if time.monotonic() >= deadline:
|
|
286
|
+
return bool(condition())
|
|
287
|
+
time.sleep(interval)
|
|
288
|
+
return True
|
|
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.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py/tests/test_buffer_reader.rst
RENAMED
|
File without changes
|
{stream2py-1.0.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py/tests/test_lock_sorted_deque.rst
RENAMED
|
File without changes
|
{stream2py-1.0.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py/tests/test_source_reader.rst
RENAMED
|
File without changes
|
{stream2py-1.0.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py/tests/test_stream_buffer.rst
RENAMED
|
File without changes
|
{stream2py-1.0.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py/tests/test_stream_source.rst
RENAMED
|
File without changes
|
|
File without changes
|
{stream2py-1.0.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py/tests/utils_for_testing.rst
RENAMED
|
File without changes
|
|
File without changes
|
{stream2py-1.0.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py/utility/locked_sorted_deque.rst
RENAMED
|
File without changes
|
{stream2py-1.0.45 → stream2py-1.0.46}/docsrc/module_docs/stream2py/utility/reader_writer_lock.rst
RENAMED
|
File without changes
|
{stream2py-1.0.45 → stream2py-1.0.46}/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
|