virt-lightning / virt-lightning

Starts your VM on libvirt in a couple of seconds!
185 stars 43 forks source link

asyncio.Event loop parameter removal in Python 3.10 #276

Closed alimiracle closed 10 months ago

alimiracle commented 11 months ago

When attempting to run Virtual Lightning (vl) on Ubuntu 22.4 with Python 3.10.6 and vl 2.3.0, users encounter a traceback error. The error originates from the virEventRegisterAsyncIOImpl function in the libvirtaio.py file, leading to a TypeError due to the removal of the loop parameter from the asyncio.Event() constructor starting from Python 3.10. Steps to Reproduce: 1. Install Ubuntu 22.4 and Python 3.10.6 on the system. 2. Install Virtual Lightning (vl) version 2.3.0 using the command: pip install vl==2.3.0. 3. Execute any vl command, such as vl up. Expected Behavior: Virtual Lightning (vl) should run without any errors and perform the intended actions without issues. Actual Behavior: Upon running any vl command, the following traceback error is encountered: Traceback (most recent call last): File "/home/ali/.local/bin/vl", line 8, in sys.exit(main()) File "/home/ali/.local/lib/python3.10/site-packages/virt_lightning/shell.py", line 382, in main action_func(configuration=configuration, *vars(args)) File "/home/ali/.local/lib/python3.10/site-packages/virt_lightning/api.py", line 180, in up _register_aio_virt_impl(loop) File "/home/ali/.local/lib/python3.10/site-packages/virt_lightning/api.py", line 67, in _register_aio_virt_impl libvirtaio.virEventRegisterAsyncIOImpl(loop=loop) File "/usr/lib/python3/dist-packages/libvirtaio.py", line 477, in virEventRegisterAsyncIOImpl _current_impl = virEventAsyncIOImpl(loop=loop).register() File "/usr/lib/python3/dist-packages/libvirtaio.py", line 285, in init self._finished = asyncio.Event(loop=loop) File "/usr/lib/python3.10/asyncio/locks.py", line 168, in init super().init(loop=loop) File "/usr/lib/python3.10/asyncio/mixins.py", line 17, in init raise TypeError( TypeError: As of 3.10, the loop* parameter was removed from Event() since it is no longer necessary Proposed Solution: To resolve the issue, the Virtual Lightning (vl) codebase should be updated to accommodate the changes made to the asyncio.Event() constructor in Python 3.10. The usage of the loop parameter should be removed from the libvirtaio.py file, and the code should be modified to work seamlessly with Python 3.10 and later versions. Workaround: As a temporary workaround, users can consider downgrading their Python version to one that is compatible with Virtual Lightning (vl) until an updated version of vl is released to address the issue. Alternatively, they can use Python 3.9.x or any version that still supports the loop parameter in the asyncio.Event() constructor.

goneri commented 11 months ago

Hi @alimiracle,

Thank you for taking the time to report this. The issue comes from the libvirt-python library and is resolved upstream, see: https://github.com/virt-lightning/virt-lightning/issues/221