Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove async_generator #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions ssb/muxrpc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from functools import wraps

from async_generator import async_generator, yield_

from ssb.packet_stream import PSMessageType


Expand Down Expand Up @@ -30,12 +28,11 @@ class MuxRPCSourceHandler(MuxRPCHandler):
def __init__(self, ps_handler):
self.ps_handler = ps_handler

@async_generator
async def __aiter__(self):
async for msg in self.ps_handler:
try:
self.check_message(msg)
await yield_(msg)
yield msg
except MuxRPCAPIException:
raise

Expand Down
8 changes: 2 additions & 6 deletions ssb/packet_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
from math import ceil

import simplejson
from async_generator import async_generator, yield_

from secret_handshake import SHSClient, SHSServer


Expand All @@ -32,13 +30,12 @@ async def process(self, msg):
async def stop(self):
await self.queue.put(None)

@async_generator
async def __aiter__(self):
while True:
elem = await self.queue.get()
if not elem:
return
await yield_(elem)
yield elem


class PSRequestHandler(object):
Expand Down Expand Up @@ -113,15 +110,14 @@ def register_handler(self, handler):
def is_connected(self):
return self.connection.is_connected

@async_generator
async def __aiter__(self):
while True:
msg = await self.read()
if not msg:
return
# filter out replies
if msg.req >= 0:
await yield_(msg)
yield msg

async def __await__(self):
async for data in self:
Expand Down