teejusb / fsr

FSR code used for dance pads
GNU General Public License v3.0
63 stars 43 forks source link

aiohttp 3.7.4 isn't compatible with asyncio in Python 3.10 #48

Closed maybe-sybr closed 1 year ago

maybe-sybr commented 2 years ago

I mentioned this on Discord a couple of months ago, but have only just gotten back into hacking on the FSR code. This issue manifests as a TypeError in aiohttp when you hit ctrl-C to interrupt the script, like so:

yarn run v1.22.18
$ cd server && venv/bin/python server.py
/home/maybe/dev/fsr/fsr/webui/server/server.py:327: DeprecationWarning: There is no current event loop
  main_thread_loop = asyncio.get_event_loop()
 * WebUI can be found at: http://10.10.9.144:5000
Found Profiles: ['']
/home/maybe/dev/fsr/fsr/webui/server/server.py:208: DeprecationWarning: isSet() is deprecated, use is_set() instead
  while not thread_stop_event.isSet():
/home/maybe/dev/fsr/fsr/webui/server/server.py:252: DeprecationWarning: isSet() is deprecated, use is_set() instead
  while not thread_stop_event.isSet():
======== Running on http://0.0.0.0:5000 ========
(Press CTRL+C to quit)
Client connected
^CTraceback (most recent call last):
  File "/home/maybe/dev/fsr/fsr/webui/server/server.py", line 460, in <module>
    web.run_app(app, port=HTTP_PORT)
  File "/home/maybe/dev/fsr/fsr/webui/server/venv/lib64/python3.10/site-packages/aiohttp/web.py", line 512, in run_app
    _cancel_tasks({main_task}, loop)
  File "/home/maybe/dev/fsr/fsr/webui/server/venv/lib64/python3.10/site-packages/aiohttp/web.py", line 444, in _cancel_tasks
    asyncio.gather(*to_cancel, loop=loop, return_exceptions=True)
TypeError: gather() got an unexpected keyword argument 'loop'

Per https://github.com/aio-libs/aiohttp/issues/5905, this just looks like the dependency in requirements.txt needs to be bumped. Installing the newer releases of aiohttp and async-timeout (>= 4.0 seems necessary) fixes the ^C issue, but causes something else to break silently so that sensor values don't get reported to the UI. The value bars and the time plot both sit at 0, even though I apply pressure to my test sensor.

No sure what the breakage with the value reporting is, if I work it out I'll follow up here or make another issue.

aeubanks commented 1 year ago

Seems to have something to do with this code being deprecated

warning when running:

fsr/webui/server/server.py:327: DeprecationWarning: There is no current event loop
  main_thread_loop = asyncio.get_event_loop()