python-evdev icon indicating copy to clipboard operation
python-evdev copied to clipboard

RuntimeError: There is no current event loop in thread [v1.3.0]

Open DmitriiCM opened this issue 5 years ago • 3 comments

Hi all,

After updating to 1.3.0 I got this error:

Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/evdev/device.py", line 159, in __del__ self.close() File "/usr/local/lib/python3.8/site-packages/evdev/device.py", line 304, in close super().close() File "/usr/local/lib/python3.8/site-packages/evdev/eventio_async.py", line 54, in close loop = asyncio.get_event_loop() File "/usr/local/lib/python3.8/asyncio/events.py", line 639, in get_event_loop raise RuntimeError('There is no current event loop in thread %r.' RuntimeError: There is no current event loop in thread 'XXXXX'.

I am not using asyncio in the project, so, please check the dependencies.

Rolling back to 1.2.0 helps.

Thanks.

DmitriiCM avatar Feb 11 '20 14:02 DmitriiCM

I am having a similar error:

Exception ignored in: <function InputDevice.__del__ at 0x7f69824dc200>
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/evdev/device.py", line 159, in __del__
  File "/usr/lib/python3/dist-packages/evdev/device.py", line 304, in close
  File "/usr/lib/python3/dist-packages/evdev/eventio_async.py", line 54, in close
  File "/usr/lib/python3.7/asyncio/events.py", line 640, in get_event_loop
  File "/usr/lib/python3.7/asyncio/events.py", line 660, in new_event_loop
  File "/usr/lib/python3.7/asyncio/unix_events.py", line 51, in __init__
  File "/usr/lib/python3.7/asyncio/selector_events.py", line 54, in __init__
  File "/usr/lib/python3.7/asyncio/base_events.py", line 372, in __init__
  File "/usr/lib/python3.7/asyncio/coroutines.py", line 28, in _is_debug_mode
AttributeError: 'NoneType' object has no attribute 'dev_mode'

Mte90 avatar Mar 04 '20 14:03 Mte90

Also a similar error here on 1.3.0, fixed by rolling back to 1.2.0. Using Python3.6.9, Ubuntu 18.04.4.

Exception ignored in: <bound method InputDevice.__del__ of InputDevice('/dev/input/event0')>
Traceback (most recent call last):
  File "/home/automator/.local/lib/python3.6/site-packages/evdev/device.py", line 159, in __del__
    self.close()
  File "/home/automator/.local/lib/python3.6/site-packages/evdev/device.py", line 304, in close
    super().close()
  File "/home/automator/.local/lib/python3.6/site-packages/evdev/eventio_async.py", line 54, in close
    loop = asyncio.get_event_loop()
  File "/usr/lib/python3.6/asyncio/events.py", line 694, in get_event_loop
    return get_event_loop_policy().get_event_loop()
  File "/usr/lib/python3.6/asyncio/events.py", line 602, in get_event_loop
    % threading.current_thread().name)
RuntimeError: There is no current event loop in thread 'Dummy-1'.

mofahead avatar Mar 20 '20 19:03 mofahead

Hello, I got the same error. After a bit of research I found that the following line causes the error (it was added in 1.3.0): https://github.com/gvalkov/python-evdev/blob/0cdf86adf9576ba343c97a31bd0368c889e8d494/evdev/device.py#L304

the call to super().close() will be redirected to the eventio_async.EventIO.close method even if async has not been used.

A quick fix would be to add: except RuntimeError: pass

to the close method.

dp0s avatar Mar 22 '20 22:03 dp0s