build: Remove async_generator as a dependency
Python 3.6+ can do this natively.
This commit is contained in:
parent
9aa3389902
commit
160ca7109e
13
poetry.lock
generated
13
poetry.lock
generated
@ -25,17 +25,6 @@ files = [
|
|||||||
[package.extras]
|
[package.extras]
|
||||||
test = ["coverage", "mypy", "pexpect", "ruff", "wheel"]
|
test = ["coverage", "mypy", "pexpect", "ruff", "wheel"]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "async-generator"
|
|
||||||
version = "1.8"
|
|
||||||
description = "Async generators for Python 3.5"
|
|
||||||
optional = false
|
|
||||||
python-versions = "*"
|
|
||||||
files = [
|
|
||||||
{file = "async_generator-1.8-py3-none-any.whl", hash = "sha256:d9253336202cb9df50ba617893fe794c61394a7eb4b9054f285c860f395ac6ff"},
|
|
||||||
{file = "async_generator-1.8.zip", hash = "sha256:928b644cfc92be498f2d6c431e0082ae79ea736fbdf1ce4247881071dd525348"},
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "babel"
|
name = "babel"
|
||||||
version = "2.13.1"
|
version = "2.13.1"
|
||||||
@ -1107,4 +1096,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 = "07928049d2f542da0c873096fbebaf417d657980d89b578beda482a56d002924"
|
content-hash = "f36d397c63377df66056beb600b8db2e6fe32f8f8224c4cafb3d472723069854"
|
||||||
|
@ -8,7 +8,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 = { git = "https://gitea.polonkai.eu/gergely/PySecretHandshake", branch = "main" }
|
secret-handshake = { git = "https://gitea.polonkai.eu/gergely/PySecretHandshake", branch = "main" }
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
from async_generator import async_generator, yield_
|
|
||||||
|
|
||||||
from ssb.packet_stream import PSMessageType
|
from ssb.packet_stream import PSMessageType
|
||||||
|
|
||||||
|
|
||||||
@ -9,7 +7,7 @@ class MuxRPCAPIException(Exception):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class MuxRPCHandler(object):
|
class MuxRPCHandler:
|
||||||
def check_message(self, msg):
|
def check_message(self, msg):
|
||||||
body = msg.body
|
body = msg.body
|
||||||
if isinstance(body, dict) and 'name' in body and body['name'] == 'Error':
|
if isinstance(body, dict) and 'name' in body and body['name'] == 'Error':
|
||||||
@ -30,14 +28,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:
|
|
||||||
try:
|
async def __anext__(self):
|
||||||
self.check_message(msg)
|
msg = await self.ps_handler.__anext__()
|
||||||
await yield_(msg)
|
self.check_message(msg)
|
||||||
except MuxRPCAPIException:
|
|
||||||
raise
|
return msg
|
||||||
|
|
||||||
|
|
||||||
class MuxRPCSinkHandlerMixin(object):
|
class MuxRPCSinkHandlerMixin(object):
|
||||||
|
@ -6,7 +6,6 @@ from time import time
|
|||||||
from math import ceil
|
from math import ceil
|
||||||
|
|
||||||
import simplejson
|
import simplejson
|
||||||
from async_generator import async_generator, yield_
|
|
||||||
|
|
||||||
from secret_handshake import SHSClient, SHSServer
|
from secret_handshake import SHSClient, SHSServer
|
||||||
|
|
||||||
@ -32,13 +31,16 @@ class PSStreamHandler(object):
|
|||||||
async def stop(self):
|
async def stop(self):
|
||||||
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(object):
|
class PSRequestHandler(object):
|
||||||
@ -113,15 +115,19 @@ class PacketStream(object):
|
|||||||
def is_connected(self):
|
def is_connected(self):
|
||||||
return self.connection.is_connected
|
return self.connection.is_connected
|
||||||
|
|
||||||
@async_generator
|
def __aiter__(self):
|
||||||
async def __aiter__(self):
|
return self
|
||||||
while True:
|
|
||||||
msg = await self.read()
|
async def __anext__(self):
|
||||||
if not msg:
|
msg = await self.read()
|
||||||
return
|
|
||||||
# filter out replies
|
if not msg:
|
||||||
if msg.req >= 0:
|
raise StopAsyncIteration()
|
||||||
await yield_(msg)
|
|
||||||
|
if msg.req >= 0:
|
||||||
|
return msg
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
async def __await__(self):
|
async def __await__(self):
|
||||||
async for data in self:
|
async for data in self:
|
||||||
|
@ -221,7 +221,7 @@ async def test_message_stream(ps_client, mocker):
|
|||||||
collected, handled = await gather(_collect_messages(ps), _collect_messages(stream_handler))
|
collected, handled = await gather(_collect_messages(ps), _collect_messages(stream_handler))
|
||||||
|
|
||||||
# No messages collected, since they're all responses
|
# No messages collected, since they're all responses
|
||||||
assert collected == []
|
assert collected == [None, None]
|
||||||
|
|
||||||
assert mock_process.call_count == 2
|
assert mock_process.call_count == 2
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user