build: Remove async_generator as a dependency

Python 3.6+ can do this natively.
This commit is contained in:
Gergely Polonkai 2023-11-01 06:03:06 +01:00
parent 01e8de96b2
commit c588967c11
4 changed files with 25 additions and 22 deletions

2
poetry.lock generated
View File

@ -1310,4 +1310,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p
[metadata] [metadata]
lock-version = "2.0" lock-version = "2.0"
python-versions = "^3.9" python-versions = "^3.9"
content-hash = "bd8b3213143f1abe13f580d28e2d42ee3d663c2d010548e7acd27be04912308a" content-hash = "d57dc0c074d7daf70507fda1fc9641cf367b6dc8f02b34a5fceafe6b45c0f4f9"

View File

@ -11,7 +11,6 @@ readme = "README.rst"
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.9" python = "^3.9"
async_generator = "^1.8"
PyNaCl = "^1.1.0" PyNaCl = "^1.1.0"
PyYAML = "^6.0.1" PyYAML = "^6.0.1"
secret-handshake = { version = "0.1.0.dev3", allow-prereleases = true } secret-handshake = { version = "0.1.0.dev3", allow-prereleases = true }

View File

@ -22,8 +22,6 @@
"""MuxRPC""" """MuxRPC"""
from async_generator import async_generator, yield_
from ssb.packet_stream import PSMessageType from ssb.packet_stream import PSMessageType
@ -61,11 +59,14 @@ class MuxRPCSourceHandler(MuxRPCHandler):
def __init__(self, ps_handler): def __init__(self, ps_handler):
self.ps_handler = ps_handler self.ps_handler = ps_handler
@async_generator def __aiter__(self):
async def __aiter__(self): return self
async for msg in self.ps_handler:
self.check_message(msg) async def __anext__(self):
await yield_(msg) msg = await self.ps_handler.__anext__()
self.check_message(msg)
return msg
class MuxRPCSinkHandlerMixin: # pylint: disable=too-few-public-methods class MuxRPCSinkHandlerMixin: # pylint: disable=too-few-public-methods

View File

@ -29,7 +29,6 @@ from math import ceil
import struct import struct
from time import time from time import time
from async_generator import async_generator, yield_
import simplejson import simplejson
logger = logging.getLogger("packet_stream") logger = logging.getLogger("packet_stream")
@ -61,13 +60,16 @@ class PSStreamHandler:
await self.queue.put(None) await self.queue.put(None)
@async_generator def __aiter__(self):
async def __aiter__(self): return self
while True:
elem = await self.queue.get() async def __anext__(self):
if not elem: elem = await self.queue.get()
return
await yield_(elem) if not elem:
raise StopAsyncIteration()
return elem
class PSRequestHandler: class PSRequestHandler:
@ -165,17 +167,18 @@ class PacketStream:
return self.connection.is_connected return self.connection.is_connected
@async_generator def __aiter__(self):
async def __aiter__(self): return self
async def __anext__(self):
while True: while True:
msg = await self.read() msg = await self.read()
if not msg: if not msg:
return raise StopAsyncIteration()
# filter out replies
if msg.req >= 0: if msg.req >= 0:
await yield_(msg) return msg
async def __await__(self): async def __await__(self):
async for data in self: async for data in self: