From fc708f1ce0b1bc8b236f50dd1a5079ef29412623 Mon Sep 17 00:00:00 2001 From: Louis Opter Date: Sat, 26 Feb 2022 12:12:12 -0800 Subject: [PATCH] Let the OS decide local_addr, and add host argument to connect method This allowed me to run serialosc and pymonome under different docker containers. --- monome.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/monome.py b/monome.py index 4c0e2f0..660855b 100644 --- a/monome.py +++ b/monome.py @@ -102,7 +102,6 @@ async def connect(self, host, port, loop=None): loop = asyncio.get_event_loop() transport, protocol = await loop.create_datagram_endpoint(lambda: self, - local_addr=('127.0.0.1', 0), remote_addr=(host, port)) def disconnect(self): @@ -237,16 +236,16 @@ def connection_made(self, transport): self.send('/serialosc/list', self.host, self.port) self.send('/serialosc/notify', self.host, self.port) - async def connect(self, loop=None): + async def connect(self, host='127.0.0.1', loop=None): if loop is None: if sys.version_info >= (3, 7): loop = asyncio.get_running_loop() else: loop = asyncio.get_event_loop() - transport, protocol = await loop.create_datagram_endpoint(lambda: self, - local_addr=('127.0.0.1', 0), - remote_addr=('127.0.0.1', 12002)) + transport, protocol = await loop.create_datagram_endpoint( + lambda: self, remote_addr=(host, 12002), + ) def _on_serialosc_device(self, addr, path, id, type, port): type = type.strip() # remove trailing spaces for arcs