Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
maybe-sybr opened this issue Jul 25, 2022 · 1 comment · Fixed by #59
Closed

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

maybe-sybr opened this issue Jul 25, 2022 · 1 comment · Fixed by #59

Comments

@maybe-sybr
Copy link

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 aio-libs/aiohttp#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
Copy link
Contributor

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()

aeubanks added a commit to aeubanks/fsr that referenced this issue Jan 26, 2023
Newer versions of python (e.g. 3.10) need upgraded aiohttp, otherwise
there are weird issues with Ctrl+C (see issue).

However, doing so also requires calling asyncio.get_event_loop() after
web.run_app() because now asyncio.get_event_loop() doesn't return a loop
if one isn't set. web.run_app() sets one.

Fixes teejusb#48
teejusb pushed a commit that referenced this issue Jan 26, 2023
Newer versions of python (e.g. 3.10) need upgraded aiohttp, otherwise
there are weird issues with Ctrl+C (see issue).

However, doing so also requires calling asyncio.get_event_loop() after
web.run_app() because now asyncio.get_event_loop() doesn't return a loop
if one isn't set. web.run_app() sets one.

Fixes #48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants