Use async connect(...)
This commit is contained in:
parent
679cfb3fa1
commit
5c7888e006
@ -207,8 +207,8 @@ class PSClient(PSConnection):
|
|||||||
self.connection.on_connect(self._on_connect)
|
self.connection.on_connect(self._on_connect)
|
||||||
self.loop = loop
|
self.loop = loop
|
||||||
|
|
||||||
def connect(self):
|
async def connect(self):
|
||||||
self.connection.connect()
|
await self.connection.connect()
|
||||||
|
|
||||||
|
|
||||||
class PSServer(PSConnection):
|
class PSServer(PSConnection):
|
||||||
|
@ -80,7 +80,7 @@ sign = SigningKey(server_prv_key[:32])
|
|||||||
|
|
||||||
loop = get_event_loop()
|
loop = get_event_loop()
|
||||||
packet_stream = PSClient('127.0.0.1', 8008, sign, server_pub_key, loop=loop)
|
packet_stream = PSClient('127.0.0.1', 8008, sign, server_pub_key, loop=loop)
|
||||||
packet_stream.connect()
|
loop.run_until_complete(packet_stream.connect())
|
||||||
api.add_connection(packet_stream)
|
api.add_connection(packet_stream)
|
||||||
|
|
||||||
loop.run_until_complete(gather(ensure_future(api), main()))
|
loop.run_until_complete(gather(ensure_future(api), main()))
|
||||||
|
@ -15,7 +15,7 @@ with open(os.path.expanduser('~/.ssb/secret')) as f:
|
|||||||
|
|
||||||
|
|
||||||
async def on_connect():
|
async def on_connect():
|
||||||
loop.create_task(ensure_future(packet_stream))
|
ensure_future(packet_stream, loop=loop)
|
||||||
|
|
||||||
# create console handler and set level to debug
|
# create console handler and set level to debug
|
||||||
ch = logging.StreamHandler()
|
ch = logging.StreamHandler()
|
||||||
|
Loading…
Reference in New Issue
Block a user