attwad / python-osc

Open Sound Control server and client in pure python
The Unlicense
514 stars 106 forks source link

python-osc does not work with uvloop #69

Open jabdoa2 opened 6 years ago

jabdoa2 commented 6 years ago

Standard asyncio loop works fine but uvloop generates an error with this lib:

ERROR : root : '_OSCProtocolFactory' object has no attribute 'dispatcher'
Traceback (most recent call last):
  File "/data/home/jan/cloud/flipper/src/mpf/mpf/commands/game.py", line 217, in __init__
    MachineController(mpf_path, machine_path, vars(self.args)).run()
  File "/data/home/jan/cloud/flipper/src/mpf/mpf/core/machine.py", line 681, in run
    self._run_loop()
  File "/data/home/jan/cloud/flipper/src/mpf/mpf/core/machine.py", line 727, in _run_loop
    raise self._exception['exception']
  File "uvloop/cbhandles.pyx", line 52, in uvloop.loop.Handle._run
  File "uvloop/handles/udp.pyx", line 64, in uvloop.loop.UDPTransport._on_read_ready
  File "/data/home/jan/cloud/flipper/src/python-osc/pythonosc/osc_server.py", line 171, in datagram_received
    _call_handlers_for_packet(data, self.dispatcher)

This seems to be related to passing a class instance as factory to create_datagram_endpoint.

attwad commented 6 years ago

Do you have any snippet you can share to see how the python-osc dispatcher ended up in the uvloop? I've personally never used it but seeing the code might help figure out what's wrong.

jabdoa2 commented 6 years ago

I think the above already happens with the sample code from your website. Just load and set uvloop before that and you will be able to see it.

attwad commented 6 years ago

I see, any python version/system this was confirmed on?

attwad commented 6 years ago

(uvloop says 3.5+, python-osc is 3.4+, just want to make sure this was confirmed on 3.5+ before diving deeper)

jabdoa2 commented 6 years ago

I tried on 3.5 or 3.6