Skip to content

Commit

Permalink
Fixed deprecated options in asyncio API for Python 3.10. Fixes #58.
Browse files Browse the repository at this point in the history
  • Loading branch information
markqvist committed May 25, 2022
1 parent 94749e0 commit 9e316ab
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions RNS/Interfaces/I2PInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ def __init__(self, rns_storagepath):
def start(self):
asyncio.set_event_loop(asyncio.new_event_loop())
self.loop = asyncio.get_event_loop()

RNS.log("Could not get event loop for "+str(self)+", waiting for event loop to appear", RNS.LOG_WARNING)
while self.loop == None:
self.loop = asyncio.get_event_loop()
sleep(0.25)

try:
self.loop.run_forever()
except Exception as e:
Expand Down
2 changes: 1 addition & 1 deletion RNS/vendor/i2plib/aiosam.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async def get_sam_socket(sam_address=sam.DEFAULT_ADDRESS, loop=None):
:param loop: (optional) event loop instance
:return: A (reader, writer) pair
"""
reader, writer = await asyncio.open_connection(*sam_address, loop=loop)
reader, writer = await asyncio.open_connection(*sam_address)
writer.write(sam.hello("3.1", "3.1"))
reply = parse_reply(await reader.readline())
if reply.ok:
Expand Down
6 changes: 3 additions & 3 deletions RNS/vendor/i2plib/tunnel.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async def handle_client(client_reader, client_writer):
self.status["setup_failed"] = True
self.status["exception"] = e

self.server = await asyncio.start_server(handle_client, *self.local_address, loop=self.loop)
self.server = await asyncio.start_server(handle_client, *self.local_address)
self.status["setup_ran"] = True

def stop(self):
Expand Down Expand Up @@ -136,8 +136,8 @@ async def handle_client(incoming, client_reader, client_writer):
remote_reader, remote_writer = await asyncio.wait_for(
asyncio.open_connection(
host=self.local_address[0],
port=self.local_address[1], loop=self.loop),
timeout=5, loop=self.loop)
port=self.local_address[1]),
timeout=5)
if data: remote_writer.write(data)
asyncio.ensure_future(proxy_data(remote_reader, client_writer),
loop=self.loop)
Expand Down

0 comments on commit 9e316ab

Please sign in to comment.