linux-automation / lxa-iobus

Linux Automation IOBus server
https://lxa-iobus.readthedocs.io/en/latest/
Apache License 2.0
3 stars 4 forks source link

Make lxa-iobus-server compatible with python 3.10 #30

Closed hnez closed 2 years ago

hnez commented 2 years ago

I've encountered two issues when running lxa-iobus-server with Python 3.10:

  1. A warning that pops up once when starting the server:

    bin/lxa-iobus-server:106: DeprecationWarning: There is no current event loop loop = asyncio.get_event_loop() starting server on http://localhost:8080/

  2. A warning that pops up very frequently:

    WARNING:LXAIOBusServer:Exception during get_info() for node <LxaNode(address=00000507.00000002.00000003.00000001, node_id=1, driver=<lxa_iobus.node_drivers.Iobus4Do3Di3AiDriver object at 0x7f1d51224cd0>)>: TypeError("wait_for() got an unexpected keyword argument 'loop'")

This MR should fix both of these warnings.

The change removing the loop= parameter from wait_for works for python versions 3.7 and higher.

SmithChart commented 2 years ago

In Python 3.7 and Python 3.9 this change leads to the following exceptions:

RuntimeError: Task <Task pending coro=<LXAIOBusServer.flash_worker() running at /home/chris/work/Projects/github/lxa-iobus/lxa_iobus/server/server.py:122>> got Future <Future pending> attached to a different loop
ERROR:LXAIOBusServer:flashing failed
Traceback (most recent call last):
  File "/home/chris/work/Projects/github/lxa-iobus/lxa_iobus/server/server.py", line 122, in flash_worker
    shutdown, node, file_name = await self.flash_jobs.get()
  File "/home/chris/.pyenv/versions/3.7.3/lib/python3.7/asyncio/queues.py", line 159, in get
    await getter

The server seems to work but logs hundreds of messages a second.