Anrijs / Aranet4-Python

Aranet4, Aranet2 and Aranet Radiation Python client
MIT License
213 stars 19 forks source link

sys:1: RuntimeWarning: coroutine 'BleakClient.disconnect' was never awaited #42

Open jonorthwash opened 5 months ago

jonorthwash commented 5 months ago

With the current commit (bfa3db5d78f02232b7fc27350744ebabd10f6165, and various ones before it), I get the following error:

$ aranetctl -r CC:47:4C:60:7A:6A
Next data point will be logged in 293 seconds
Traceback (most recent call last):
  File "/usr/local/bin/aranetctl", line 33, in <module>
    sys.exit(load_entry_point('aranet4==2.3.2', 'console_scripts', 'aranetctl')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/aranet4-2.3.2-py3.11.egg/aranet4/aranetctl.py", line 247, in entry_point
  File "/usr/local/lib/python3.11/dist-packages/aranet4-2.3.2-py3.11.egg/aranet4/aranetctl.py", line 235, in main
  File "/usr/local/lib/python3.11/dist-packages/aranet4-2.3.2-py3.11.egg/aranet4/client.py", line 990, in get_all_records
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/aranet4-2.3.2-py3.11.egg/aranet4/client.py", line 969, in _all_records
UnboundLocalError: cannot access local variable 'rad_dose_rate_val' where it is not associated with a value
Exception ignored in: <function Aranet4.__del__ at 0x7fb66f07c0>
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/aranet4-2.3.2-py3.11.egg/aranet4/client.py", line 521, in __del__
  File "/usr/lib/python3.11/asyncio/tasks.py", line 874, in shield
  File "/usr/lib/python3.11/asyncio/tasks.py", line 668, in _ensure_future
  File "/usr/lib/python3.11/asyncio/events.py", line 677, in get_event_loop
RuntimeError: There is no current event loop in thread 'MainThread'.
sys:1: RuntimeWarning: coroutine 'BleakClient.disconnect' was never awaited

With older commits (e.g., 5a88f6e7806718242f10a328abfaf88849d2760c), it returns records as expected.

I haven't (yet) bifurcated revisions to find out where it broke.

jonorthwash commented 5 months ago

Commit 3d0013cdcf35fa427de38585b1bb3f65f07ef40b works fine, and commit f9b538889c38d724416b8eb861dc30a897d35c9d is broken.

thecode commented 5 months ago

Hi, Can you manually downgrade aranet4 and confirm if it fixes the issue? If you can shell into home assistant container you can use:

sed -i 's/aranet4==2.3.3/aranet4==2.2.2/g' /usr/src/homeassistant/homeassistant/components/aranet/manifest.json

Restart core after this to apply the changes.

To validate your changes are in place (run inside the container):

cat /usr/src/homeassistant/homeassistant/components/aranet/manifest.json | grep aranet4
pip show aranet4

Thanks

Viss commented 5 months ago

how can someone running hassos on raspberry pi get to that json file? its inaccessible via HA's terminal or if you ssh in

jonorthwash commented 4 months ago

Can you manually downgrade aranet4 and confirm if it fixes the issue?

This is exactly what I reported having done above.

If you can shell into home assistant container you can use:

I am not running this in a container, but on vanilla Raspberry Pi OS.

Anrijs commented 4 months ago

Try latest version - 2.3.4

thecode commented 4 months ago

@jonorthwash I apologize, I commented on this issue by mistake, it is not relevant to this (however should be resolved by 2.3.4)