omlish 0.0.0.dev195__py3-none-any.whl → 0.0.0.dev197__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. omlish/__about__.py +3 -3
  2. omlish/asyncs/asyncio/all.py +0 -1
  3. omlish/asyncs/asyncio/asyncio.py +2 -6
  4. omlish/asyncs/bluelet/runner.py +1 -1
  5. omlish/asyncs/bridge.py +2 -2
  6. omlish/codecs/base.py +5 -5
  7. omlish/codecs/text.py +1 -2
  8. omlish/io/compress/adapters.py +4 -4
  9. omlish/io/compress/base.py +4 -4
  10. omlish/io/compress/bz2.py +4 -4
  11. omlish/io/compress/codecs.py +2 -2
  12. omlish/io/compress/gzip.py +10 -10
  13. omlish/io/compress/lz4.py +5 -5
  14. omlish/io/compress/lzma.py +4 -4
  15. omlish/io/compress/zlib.py +4 -4
  16. omlish/io/coro/__init__.py +56 -0
  17. omlish/io/coro/direct.py +13 -0
  18. omlish/io/{generators → coro}/readers.py +31 -31
  19. omlish/io/{generators → coro}/stepped.py +28 -28
  20. omlish/multiprocessing/__init__.py +32 -0
  21. omlish/{multiprocessing.py → multiprocessing/death.py} +3 -88
  22. omlish/multiprocessing/proxies.py +30 -0
  23. omlish/multiprocessing/spawn.py +59 -0
  24. omlish/os/atomics.py +2 -2
  25. omlish/outcome.py +250 -0
  26. omlish/sockets/server.py +1 -2
  27. omlish/term/vt100/terminal.py +1 -1
  28. omlish/testing/pytest/__init__.py +0 -4
  29. omlish/testing/pytest/plugins/asyncs/__init__.py +1 -0
  30. omlish/testing/pytest/plugins/asyncs/backends/__init__.py +16 -0
  31. omlish/testing/pytest/plugins/asyncs/backends/asyncio.py +35 -0
  32. omlish/testing/pytest/plugins/asyncs/backends/base.py +30 -0
  33. omlish/testing/pytest/plugins/asyncs/backends/trio.py +91 -0
  34. omlish/testing/pytest/plugins/asyncs/backends/trio_asyncio.py +89 -0
  35. omlish/testing/pytest/plugins/asyncs/consts.py +3 -0
  36. omlish/testing/pytest/plugins/asyncs/fixtures.py +273 -0
  37. omlish/testing/pytest/plugins/asyncs/plugin.py +182 -0
  38. omlish/testing/pytest/plugins/asyncs/utils.py +10 -0
  39. omlish/testing/pytest/plugins/managermarks.py +0 -14
  40. omlish/text/indent.py +1 -1
  41. omlish/text/minja.py +2 -2
  42. {omlish-0.0.0.dev195.dist-info → omlish-0.0.0.dev197.dist-info}/METADATA +5 -5
  43. {omlish-0.0.0.dev195.dist-info → omlish-0.0.0.dev197.dist-info}/RECORD +48 -36
  44. {omlish-0.0.0.dev195.dist-info → omlish-0.0.0.dev197.dist-info}/WHEEL +1 -1
  45. omlish/io/generators/__init__.py +0 -56
  46. omlish/io/generators/direct.py +0 -13
  47. omlish/testing/pytest/marks.py +0 -18
  48. omlish/testing/pytest/plugins/asyncs.py +0 -162
  49. /omlish/io/{generators → coro}/consts.py +0 -0
  50. {omlish-0.0.0.dev195.dist-info → omlish-0.0.0.dev197.dist-info}/LICENSE +0 -0
  51. {omlish-0.0.0.dev195.dist-info → omlish-0.0.0.dev197.dist-info}/entry_points.txt +0 -0
  52. {omlish-0.0.0.dev195.dist-info → omlish-0.0.0.dev197.dist-info}/top_level.txt +0 -0
omlish/__about__.py CHANGED
@@ -1,5 +1,5 @@
1
- __version__ = '0.0.0.dev195'
2
- __revision__ = '8bbac0c946d60a9f0b3d684c3f701165d7247971'
1
+ __version__ = '0.0.0.dev197'
2
+ __revision__ = 'e4b51b7c95116d97eddbd8f1a37a1c1a42cc8e39'
3
3
 
4
4
 
5
5
  #
@@ -32,7 +32,7 @@ class Project(ProjectBase):
32
32
 
33
33
  optional_dependencies = {
34
34
  'async': [
35
- 'anyio ~= 4.7',
35
+ 'anyio ~= 4.8',
36
36
  'sniffio ~= 1.3',
37
37
 
38
38
  'greenlet ~= 3.1',
@@ -1,7 +1,6 @@
1
1
  # ruff: noqa: I001
2
2
  from .asyncio import ( # noqa
3
3
  asyncio_once,
4
- get_real_current_loop,
5
4
  drain_tasks,
6
5
  draining_asyncio_tasks,
7
6
  )
@@ -20,13 +20,9 @@ def asyncio_once(fn: CallableT) -> CallableT:
20
20
  return ta.cast(CallableT, inner)
21
21
 
22
22
 
23
- def get_real_current_loop() -> asyncio.AbstractEventLoop | None:
24
- return asyncio.get_event_loop_policy()._local._loop # type: ignore # noqa
25
-
26
-
27
23
  def drain_tasks(loop=None):
28
24
  if loop is None:
29
- loop = get_real_current_loop()
25
+ loop = asyncio.get_running_loop()
30
26
 
31
27
  while loop._ready or loop._scheduled: # noqa
32
28
  loop._run_once() # noqa
@@ -34,7 +30,7 @@ def drain_tasks(loop=None):
34
30
 
35
31
  @contextlib.contextmanager
36
32
  def draining_asyncio_tasks() -> ta.Iterator[None]:
37
- loop = get_real_current_loop()
33
+ loop = asyncio.get_running_loop()
38
34
  try:
39
35
  yield
40
36
  finally:
@@ -233,7 +233,7 @@ class _BlueletRunner:
233
233
 
234
234
  try:
235
235
  if is_exc:
236
- next_event = coro.throw(*value)
236
+ next_event = coro.throw(value[0])
237
237
  else:
238
238
  next_event = coro.send(value)
239
239
 
omlish/asyncs/bridge.py CHANGED
@@ -86,7 +86,7 @@ class BridgeAwaitRequiredError(Exception):
86
86
  pass
87
87
 
88
88
 
89
- class MissingBridgeGreenletError(Exception):
89
+ class MissingBridgeThreadletError(Exception):
90
90
  pass
91
91
 
92
92
 
@@ -224,7 +224,7 @@ def s_to_a_await(awaitable: ta.Awaitable[T]) -> T:
224
224
 
225
225
  if not getattr(g.underlying, _BRIDGE_THREADLET_ATTR, False):
226
226
  _safe_cancel_awaitable(awaitable)
227
- raise MissingBridgeGreenletError
227
+ raise MissingBridgeThreadletError
228
228
 
229
229
  return check.not_none(g.parent).switch(awaitable)
230
230
 
omlish/codecs/base.py CHANGED
@@ -7,11 +7,11 @@ TODO:
7
7
  import abc
8
8
  import typing as ta
9
9
 
10
- from omlish import check
11
- from omlish import dataclasses as dc
12
- from omlish import lang
13
- from omlish import reflect as rfl
14
- from omlish.funcs import pairs as fps
10
+ from .. import check
11
+ from .. import dataclasses as dc
12
+ from .. import lang
13
+ from .. import reflect as rfl
14
+ from ..funcs import pairs as fps
15
15
 
16
16
 
17
17
  I = ta.TypeVar('I')
omlish/codecs/text.py CHANGED
@@ -3,8 +3,7 @@ import dataclasses as dc
3
3
  import functools
4
4
  import typing as ta
5
5
 
6
- from omlish import check
7
-
6
+ from .. import check
8
7
  from .base import Codec
9
8
  from .base import ComboCodec
10
9
  from .standard import STANDARD_CODECS
@@ -37,8 +37,8 @@
37
37
  import typing as ta
38
38
 
39
39
  from ... import check
40
- from ..generators import BytesSteppedGenerator
41
- from ..generators import BytesSteppedReaderGenerator
40
+ from ..coro import BytesSteppedCoro
41
+ from ..coro import BytesSteppedReaderCoro
42
42
  from .abc import CompressorObject
43
43
  from .abc import NeedsInputDecompressorObject
44
44
  from .abc import UnconsumedTailDecompressorObject
@@ -56,7 +56,7 @@ class CompressorObjectIncrementalAdapter:
56
56
 
57
57
  self._factory = factory
58
58
 
59
- def __call__(self) -> BytesSteppedGenerator:
59
+ def __call__(self) -> BytesSteppedCoro:
60
60
  compressor = self._factory()
61
61
 
62
62
  while True:
@@ -89,7 +89,7 @@ class DecompressorObjectIncrementalAdapter:
89
89
  self._factory = factory
90
90
  self._trailing_error = trailing_error
91
91
 
92
- def __call__(self) -> BytesSteppedReaderGenerator:
92
+ def __call__(self) -> BytesSteppedReaderCoro:
93
93
  pos = 0
94
94
 
95
95
  data = None # Default if EOF is encountered
@@ -1,7 +1,7 @@
1
1
  import abc
2
2
 
3
- from ..generators import BytesSteppedGenerator
4
- from ..generators import BytesSteppedReaderGenerator
3
+ from ..coro import BytesSteppedCoro
4
+ from ..coro import BytesSteppedReaderCoro
5
5
 
6
6
 
7
7
  class Compression(abc.ABC):
@@ -16,9 +16,9 @@ class Compression(abc.ABC):
16
16
 
17
17
  class IncrementalCompression(abc.ABC):
18
18
  @abc.abstractmethod
19
- def compress_incremental(self) -> BytesSteppedGenerator[None]:
19
+ def compress_incremental(self) -> BytesSteppedCoro[None]:
20
20
  raise NotImplementedError
21
21
 
22
22
  @abc.abstractmethod
23
- def decompress_incremental(self) -> BytesSteppedReaderGenerator[None]:
23
+ def decompress_incremental(self) -> BytesSteppedReaderCoro[None]:
24
24
  raise NotImplementedError
omlish/io/compress/bz2.py CHANGED
@@ -3,8 +3,8 @@ import functools
3
3
  import typing as ta
4
4
 
5
5
  from ... import lang
6
- from ..generators import BytesSteppedGenerator
7
- from ..generators import BytesSteppedReaderGenerator
6
+ from ..coro import BytesSteppedCoro
7
+ from ..coro import BytesSteppedReaderCoro
8
8
  from .adapters import CompressorObjectIncrementalAdapter
9
9
  from .adapters import DecompressorObjectIncrementalAdapter
10
10
  from .base import Compression
@@ -37,7 +37,7 @@ class Bz2Compression(Compression, IncrementalCompression):
37
37
  d,
38
38
  )
39
39
 
40
- def compress_incremental(self) -> BytesSteppedGenerator[None]:
40
+ def compress_incremental(self) -> BytesSteppedCoro[None]:
41
41
  return lang.nextgen(CompressorObjectIncrementalAdapter(
42
42
  functools.partial(
43
43
  bz2.BZ2Compressor, # type: ignore
@@ -45,7 +45,7 @@ class Bz2Compression(Compression, IncrementalCompression):
45
45
  ),
46
46
  )())
47
47
 
48
- def decompress_incremental(self) -> BytesSteppedReaderGenerator[None]:
48
+ def decompress_incremental(self) -> BytesSteppedReaderCoro[None]:
49
49
  return DecompressorObjectIncrementalAdapter(
50
50
  bz2.BZ2Decompressor, # type: ignore
51
51
  trailing_error=OSError,
@@ -2,7 +2,7 @@ import dataclasses as dc
2
2
  import typing as ta
3
3
 
4
4
  from ... import codecs
5
- from ..generators import buffer_bytes_stepped_reader_generator
5
+ from ..coro import buffer_bytes_stepped_reader_coro
6
6
  from .base import Compression
7
7
  from .base import IncrementalCompression
8
8
 
@@ -32,7 +32,7 @@ class CompressionIncrementalCodec(codecs.IncrementalCodec[bytes, bytes]):
32
32
  return self.compression.compress_incremental()
33
33
 
34
34
  def decode_incremental(self) -> ta.Generator[bytes | None, bytes, None]:
35
- return buffer_bytes_stepped_reader_generator(self.compression.decompress_incremental())
35
+ return buffer_bytes_stepped_reader_coro(self.compression.decompress_incremental())
36
36
 
37
37
 
38
38
  ##
@@ -43,9 +43,9 @@ import typing as ta
43
43
  from ... import cached
44
44
  from ... import check
45
45
  from ... import lang
46
- from ..generators import BytesSteppedGenerator
47
- from ..generators import BytesSteppedReaderGenerator
48
- from ..generators.readers import PrependableBytesGeneratorReader
46
+ from ..coro import BytesSteppedCoro
47
+ from ..coro import BytesSteppedReaderCoro
48
+ from ..coro.readers import PrependableBytesCoroReader
49
49
  from .base import Compression
50
50
  from .base import IncrementalCompression
51
51
  from .codecs import make_compression_codec
@@ -86,13 +86,13 @@ class GzipCompression(Compression, IncrementalCompression):
86
86
  d,
87
87
  )
88
88
 
89
- def compress_incremental(self) -> BytesSteppedGenerator[None]:
89
+ def compress_incremental(self) -> BytesSteppedCoro[None]:
90
90
  return lang.nextgen(IncrementalGzipCompressor(
91
91
  level=self.level,
92
92
  mtime=self.mtime,
93
93
  )())
94
94
 
95
- def decompress_incremental(self) -> BytesSteppedReaderGenerator[None]:
95
+ def decompress_incremental(self) -> BytesSteppedReaderCoro[None]:
96
96
  return IncrementalGzipDecompressor()()
97
97
 
98
98
 
@@ -159,7 +159,7 @@ class IncrementalGzipCompressor:
159
159
  if fname:
160
160
  check.none((yield fname + b'\000'))
161
161
 
162
- def __call__(self) -> BytesSteppedGenerator:
162
+ def __call__(self) -> BytesSteppedCoro:
163
163
  crc = _zero_crc()
164
164
  size = 0
165
165
  offset = 0 # Current file offset for seek(), tell(), etc
@@ -222,7 +222,7 @@ class IncrementalGzipDecompressor:
222
222
 
223
223
  def _read_gzip_header(
224
224
  self,
225
- rdr: PrependableBytesGeneratorReader,
225
+ rdr: PrependableBytesCoroReader,
226
226
  ) -> ta.Generator[int | None, bytes, int | None]:
227
227
  magic = yield from rdr.read(2)
228
228
  if magic == b'':
@@ -264,7 +264,7 @@ class IncrementalGzipDecompressor:
264
264
 
265
265
  def _read_eof(
266
266
  self,
267
- rdr: PrependableBytesGeneratorReader,
267
+ rdr: PrependableBytesCoroReader,
268
268
  crc: int,
269
269
  stream_size: int,
270
270
  ) -> ta.Generator[int | None, bytes, None]:
@@ -286,8 +286,8 @@ class IncrementalGzipDecompressor:
286
286
  if c:
287
287
  rdr.prepend(c)
288
288
 
289
- def __call__(self) -> BytesSteppedReaderGenerator:
290
- rdr = PrependableBytesGeneratorReader()
289
+ def __call__(self) -> BytesSteppedReaderCoro:
290
+ rdr = PrependableBytesCoroReader()
291
291
 
292
292
  pos = 0 # Current offset in decompressed stream
293
293
 
omlish/io/compress/lz4.py CHANGED
@@ -3,7 +3,7 @@ import typing as ta
3
3
 
4
4
  from ... import check
5
5
  from ... import lang
6
- from ..generators import BytesSteppedGenerator
6
+ from ..coro import BytesSteppedCoro
7
7
  from .base import Compression
8
8
  from .base import IncrementalCompression
9
9
  from .codecs import make_compression_codec
@@ -46,7 +46,7 @@ class Lz4Compression(Compression, IncrementalCompression):
46
46
  )
47
47
 
48
48
  @lang.autostart
49
- def compress_incremental(self) -> BytesSteppedGenerator[None]:
49
+ def compress_incremental(self) -> BytesSteppedCoro[None]:
50
50
  with lz4_frame.LZ4FrameCompressor(
51
51
  compression_level=self.level,
52
52
  block_size=self.block_size,
@@ -69,9 +69,9 @@ class Lz4Compression(Compression, IncrementalCompression):
69
69
  yield o
70
70
 
71
71
  @lang.autostart
72
- def decompress_incremental(self) -> BytesSteppedGenerator[None]:
73
- # lz4 lib does internal buffering so this is simply a BytesSteppedGenerator not a BytesSteppedReaderGenerator as
74
- # it only yields None, accepting any number of bytes at a time.
72
+ def decompress_incremental(self) -> BytesSteppedCoro[None]:
73
+ # lz4 lib does internal buffering so this is simply a BytesSteppedCoro not a BytesSteppedReaderCoro as it
74
+ # only yields None, accepting any number of bytes at a time.
75
75
  with lz4_frame.LZ4FrameDecompressor() as decompressor:
76
76
  while True:
77
77
  i = check.isinstance((yield None), bytes)
@@ -3,8 +3,8 @@ import functools
3
3
  import typing as ta
4
4
 
5
5
  from ... import lang
6
- from ..generators import BytesSteppedGenerator
7
- from ..generators import BytesSteppedReaderGenerator
6
+ from ..coro import BytesSteppedCoro
7
+ from ..coro import BytesSteppedReaderCoro
8
8
  from .adapters import CompressorObjectIncrementalAdapter
9
9
  from .adapters import DecompressorObjectIncrementalAdapter
10
10
  from .base import Compression
@@ -49,7 +49,7 @@ class LzmaCompression(Compression, IncrementalCompression):
49
49
  filters=self.filters, # type: ignore[arg-type]
50
50
  )
51
51
 
52
- def compress_incremental(self) -> BytesSteppedGenerator[None]:
52
+ def compress_incremental(self) -> BytesSteppedCoro[None]:
53
53
  return lang.nextgen(CompressorObjectIncrementalAdapter(
54
54
  functools.partial( # type: ignore
55
55
  lzma.LZMACompressor,
@@ -60,7 +60,7 @@ class LzmaCompression(Compression, IncrementalCompression):
60
60
  ),
61
61
  )())
62
62
 
63
- def decompress_incremental(self) -> BytesSteppedReaderGenerator[None]:
63
+ def decompress_incremental(self) -> BytesSteppedReaderCoro[None]:
64
64
  return DecompressorObjectIncrementalAdapter(
65
65
  functools.partial( # type: ignore
66
66
  lzma.LZMADecompressor,
@@ -3,8 +3,8 @@ import functools
3
3
  import typing as ta
4
4
 
5
5
  from ... import lang
6
- from ..generators import BytesSteppedGenerator
7
- from ..generators import BytesSteppedReaderGenerator
6
+ from ..coro import BytesSteppedCoro
7
+ from ..coro import BytesSteppedReaderCoro
8
8
  from .adapters import CompressorObjectIncrementalAdapter
9
9
  from .adapters import DecompressorObjectIncrementalAdapter
10
10
  from .base import Compression
@@ -43,7 +43,7 @@ class ZlibCompression(Compression, IncrementalCompression):
43
43
  **(dict(wbits=self.wbits) if self.wbits is not None else {}),
44
44
  )
45
45
 
46
- def compress_incremental(self) -> BytesSteppedGenerator[None]:
46
+ def compress_incremental(self) -> BytesSteppedCoro[None]:
47
47
  return lang.nextgen(CompressorObjectIncrementalAdapter(
48
48
  functools.partial(
49
49
  zlib.compressobj, # type: ignore
@@ -54,7 +54,7 @@ class ZlibCompression(Compression, IncrementalCompression):
54
54
  ),
55
55
  )())
56
56
 
57
- def decompress_incremental(self) -> BytesSteppedReaderGenerator[None]:
57
+ def decompress_incremental(self) -> BytesSteppedReaderCoro[None]:
58
58
  return DecompressorObjectIncrementalAdapter(
59
59
  functools.partial( # type: ignore
60
60
  zlib.decompressobj,
@@ -0,0 +1,56 @@
1
+ from .consts import ( # noqa
2
+ DEFAULT_BUFFER_SIZE,
3
+ )
4
+
5
+ from .direct import ( # noqa
6
+ DirectCoro,
7
+
8
+ BytesDirectCoro,
9
+ StrDirectCoro,
10
+ )
11
+
12
+ from .readers import ( # noqa
13
+ ReaderCoro,
14
+ BytesReaderCoro,
15
+ StrReaderCoro,
16
+
17
+ ExactReaderCoro,
18
+ BytesExactReaderCoro,
19
+ StrExactReaderCoro,
20
+
21
+ CoroReader,
22
+
23
+ PrependableCoroReader,
24
+ PrependableBytesCoroReader,
25
+ PrependableStrCoroReader,
26
+ prependable_bytes_coro_reader,
27
+ prependable_str_coro_reader,
28
+
29
+ BufferedCoroReader,
30
+ BufferedBytesCoroReader,
31
+ BufferedStrCoroReader,
32
+ buffered_bytes_coro_reader,
33
+ buffered_str_coro_reader,
34
+ )
35
+
36
+ from .stepped import ( # noqa
37
+ SteppedCoro,
38
+ BytesSteppedCoro,
39
+ StrSteppedCoro,
40
+ BytesToStrSteppedCoro,
41
+ StrToBytesSteppedCoro,
42
+
43
+ SteppedReaderCoro,
44
+ BytesSteppedReaderCoro,
45
+ StrSteppedReaderCoro,
46
+
47
+ flatmap_stepped_coro,
48
+
49
+ joined_bytes_stepped_coro,
50
+ joined_str_stepped_coro,
51
+
52
+ read_into_bytes_stepped_coro,
53
+ read_into_str_stepped_coro,
54
+
55
+ buffer_bytes_stepped_reader_coro,
56
+ )
@@ -0,0 +1,13 @@
1
+ import typing as ta
2
+
3
+
4
+ O = ta.TypeVar('O')
5
+ I = ta.TypeVar('I')
6
+ R = ta.TypeVar('R')
7
+
8
+
9
+ # Direct coros yield outputs 1:1 with inputs.
10
+ DirectCoro: ta.TypeAlias = ta.Generator[O, I, R]
11
+
12
+ BytesDirectCoro: ta.TypeAlias = DirectCoro[bytes, bytes, R]
13
+ StrDirectCoro: ta.TypeAlias = DirectCoro[str, str, R]
@@ -1,6 +1,6 @@
1
1
  """
2
2
  TODO:
3
- - BufferedBytesGeneratorReader
3
+ - BufferedBytesCoroReader
4
4
  - docstrings
5
5
  - memoryviews
6
6
  """
@@ -20,18 +20,18 @@ R = ta.TypeVar('R')
20
20
  AnyT = ta.TypeVar('AnyT', bound=ta.Any)
21
21
 
22
22
 
23
- # Reader generators yield ints of amounts of data needed, or None for needing any amount of data.
24
- ReaderGenerator: ta.TypeAlias = ta.Generator[int | None, I, R]
23
+ # Reader coros yield ints of amounts of data needed, or None for needing any amount of data.
24
+ ReaderCoro: ta.TypeAlias = ta.Generator[int | None, I, R]
25
25
 
26
- BytesReaderGenerator: ta.TypeAlias = ReaderGenerator[bytes, R]
27
- StrReaderGenerator: ta.TypeAlias = ReaderGenerator[str, R]
26
+ BytesReaderCoro: ta.TypeAlias = ReaderCoro[bytes, R]
27
+ StrReaderCoro: ta.TypeAlias = ReaderCoro[str, R]
28
28
 
29
29
 
30
- # Exact reader generators always specify read sizes.
31
- ExactReaderGenerator: ta.TypeAlias = ta.Generator[int, I, R]
30
+ # Exact reader coros always specify read sizes.
31
+ ExactReaderCoro: ta.TypeAlias = ta.Generator[int, I, R]
32
32
 
33
- BytesExactReaderGenerator: ta.TypeAlias = ExactReaderGenerator[bytes, R]
34
- StrExactReaderGenerator: ta.TypeAlias = ExactReaderGenerator[str, R]
33
+ BytesExactReaderCoro: ta.TypeAlias = ExactReaderCoro[bytes, R]
34
+ StrExactReaderCoro: ta.TypeAlias = ExactReaderCoro[str, R]
35
35
 
36
36
 
37
37
  ##
@@ -50,22 +50,22 @@ class _StrJoiner:
50
50
  ##
51
51
 
52
52
 
53
- class GeneratorReader(abc.ABC, ta.Generic[T]):
53
+ class CoroReader(abc.ABC, ta.Generic[T]):
54
54
  @abc.abstractmethod
55
- def read(self, sz: int | None) -> ReaderGenerator[T, T]:
55
+ def read(self, sz: int | None) -> ReaderCoro[T, T]:
56
56
  raise NotImplementedError
57
57
 
58
- def read_exact(self, sz: int) -> ReaderGenerator[T, T]:
58
+ def read_exact(self, sz: int) -> ReaderCoro[T, T]:
59
59
  d: ta.Any = yield from self.read(sz)
60
60
  if len(d) != sz:
61
- raise EOFError(f'GeneratorReader got {len(d)}, expected {sz}')
61
+ raise EOFError(f'CoroReader got {len(d)}, expected {sz}')
62
62
  return d
63
63
 
64
64
 
65
65
  ##
66
66
 
67
67
 
68
- class PrependableGeneratorReader(GeneratorReader[AnyT]):
68
+ class PrependableCoroReader(CoroReader[AnyT]):
69
69
  def __init__(self) -> None:
70
70
  super().__init__()
71
71
 
@@ -75,7 +75,7 @@ class PrependableGeneratorReader(GeneratorReader[AnyT]):
75
75
  def _join(self, lst: list[AnyT]) -> AnyT:
76
76
  raise NotImplementedError
77
77
 
78
- def read(self, sz: int | None) -> ReaderGenerator[AnyT, AnyT]:
78
+ def read(self, sz: int | None) -> ReaderCoro[AnyT, AnyT]:
79
79
  if not self._queue:
80
80
  d: AnyT = check.not_none((yield sz))
81
81
  return d
@@ -112,28 +112,28 @@ class PrependableGeneratorReader(GeneratorReader[AnyT]):
112
112
  self._queue.insert(0, (d, p or 0))
113
113
 
114
114
 
115
- class PrependableBytesGeneratorReader(
115
+ class PrependableBytesCoroReader(
116
116
  _BytesJoiner,
117
- PrependableGeneratorReader[bytes],
117
+ PrependableCoroReader[bytes],
118
118
  ):
119
119
  pass
120
120
 
121
121
 
122
- class PrependableStrGeneratorReader(
122
+ class PrependableStrCoroReader(
123
123
  _StrJoiner,
124
- PrependableGeneratorReader[str],
124
+ PrependableCoroReader[str],
125
125
  ):
126
126
  pass
127
127
 
128
128
 
129
- prependable_bytes_generator_reader = PrependableBytesGeneratorReader
130
- prependable_str_generator_reader = PrependableStrGeneratorReader
129
+ prependable_bytes_coro_reader = PrependableBytesCoroReader
130
+ prependable_str_coro_reader = PrependableStrCoroReader
131
131
 
132
132
 
133
133
  ##
134
134
 
135
135
 
136
- class BufferedGeneratorReader(PrependableGeneratorReader[AnyT], abc.ABC):
136
+ class BufferedCoroReader(PrependableCoroReader[AnyT], abc.ABC):
137
137
  def __init__(
138
138
  self,
139
139
  buffer_size: int = DEFAULT_BUFFER_SIZE,
@@ -144,7 +144,7 @@ class BufferedGeneratorReader(PrependableGeneratorReader[AnyT], abc.ABC):
144
144
 
145
145
  self._buffer_size = buffer_size
146
146
 
147
- def read(self, sz: int | None) -> ReaderGenerator[AnyT, AnyT]:
147
+ def read(self, sz: int | None) -> ReaderCoro[AnyT, AnyT]:
148
148
  g = super().read(sz)
149
149
  i: ta.Any = None
150
150
  while True:
@@ -169,21 +169,21 @@ class BufferedGeneratorReader(PrependableGeneratorReader[AnyT], abc.ABC):
169
169
  self.prepend(d, q)
170
170
 
171
171
 
172
- class BufferedBytesGeneratorReader(
172
+ class BufferedBytesCoroReader(
173
173
  _BytesJoiner,
174
- BufferedGeneratorReader[bytes],
175
- PrependableGeneratorReader[bytes],
174
+ BufferedCoroReader[bytes],
175
+ PrependableCoroReader[bytes],
176
176
  ):
177
177
  pass
178
178
 
179
179
 
180
- class BufferedStrGeneratorReader(
180
+ class BufferedStrCoroReader(
181
181
  _StrJoiner,
182
- BufferedGeneratorReader[str],
183
- PrependableGeneratorReader[str],
182
+ BufferedCoroReader[str],
183
+ PrependableCoroReader[str],
184
184
  ):
185
185
  pass
186
186
 
187
187
 
188
- buffered_bytes_generator_reader = BufferedBytesGeneratorReader
189
- buffered_str_generator_reader = BufferedStrGeneratorReader
188
+ buffered_bytes_coro_reader = BufferedBytesCoroReader
189
+ buffered_str_coro_reader = BufferedStrCoroReader