build: Remove async_generator as a dependency

As Python <3.6 is no longer supported, this library is obsolete.
This commit is contained in:
2023-10-30 06:46:19 +01:00
parent 93f2d329a4
commit 5cd7cba3df
4 changed files with 21 additions and 27 deletions

View File

@@ -1,7 +1,6 @@
import struct
from asyncio import IncompleteReadError
from async_generator import async_generator, yield_
from nacl.secret import SecretBox
from .util import inc_nonce, split_chunks
@@ -59,13 +58,16 @@ class UnboxStream(object):
self.nonce = inc_nonce(inc_nonce(self.nonce))
return body
@async_generator
async def __aiter__(self):
while True:
data = await self.read()
if data is None:
return
await yield_(data)
def __aiter__(self):
return self
async def __anext__(self):
data = await self.read()
if data is None:
raise StopAsyncIteration()
return data
class BoxStream(object):

View File

@@ -21,8 +21,6 @@
import asyncio
from async_generator import async_generator, yield_
from .boxstream import get_stream_pair
from .crypto import SHSClientCrypto, SHSServerCrypto
@@ -48,10 +46,16 @@ class SHSDuplexStream(object):
self.read_stream.close()
self.is_connected = False
@async_generator
async def __aiter__(self):
async for msg in self.read_stream:
await yield_(msg)
def __aiter__(self):
return self
async def __anext__(self):
msg = await self.read()
if msg is None:
raise StopAsyncIteration()
return msg
class SHSEndpoint(object):