question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Event loop stopped before Future completed

See original GitHub issue

Hello,

I think this is linked to https://github.com/custom-components/ble_monitor/issues/167, but since I upgraded to Home Assistant OS 5.12 yesterday, I have trouble with my bluetooth temperature sensors. I don’t see any other event that could have cause an issue, before that it was working perfectly well for months.

Now I can see this error multiple times in the logs: **ERROR (Thread-3) [custom_components.ble_monitor] HCIdump thread: Runtime error while stop scan request on hci0: Event loop stopped before Future completed.**

By reading the previous issue, I didn’t really get what was the solution.

Additional info: I am running “pure” HassOS on RPI 4B, so I don’t have access to root or to the linux behind or to commands like hcitool, the only command that seems to work is bluetoothctl, with which I already tried to re-enable everything and repair all devices without success. Another info, I use an external dongle (I identified its mac address by plugging it/unplugging it and by seing the output of bluetoothctl list command, and I set the external one as default controller with bluetoothctl)

Config:

ble_monitor:
  decimals: 1
  period: 60
  log_spikes: False
  use_median: False
  active_scan: False
  hci_interface:
    - 1
    - 0
  batt_entities: True
  discovery: False
  restore_state: False 
  report_unknown: False
  devices:
    - mac: 'xxx'
      name: 'xxx'
      temperature_unit: C

Thanks for the help !

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:126

github_iconTop GitHub Comments

5reactions
stealscommented, Jan 6, 2022

I’ve finally found out the root cause… it was permission issues for python…

When home assistant installed in pyenv the output of the command which python3 looks like /home/homeassistant/.pyenv/shims/python3 but this is not the real link to actual python3 interpreter. The actual binary placed in the folder like /home/homeassistant/.pyenv/versions/3.9.9/bin/python3.9 (it might slightly differ depending on the installed python version). So to grant root access to python it’s required to run setcap command with correct path, i.e. setcap 'cap_net_raw,cap_net_admin+eip' /home/homeassistant/.pyenv/versions/3.9.9/bin/python3.9

3reactions
Ernst79commented, Jan 19, 2022

Did you check the FAQ? The FAQ gives some tips how to solve this (in most cases)

https://custom-components.github.io/ble_monitor/faq#i-get-a-runtimeerror-event-loop-stopped-before-future-completed

Read more comments on GitHub >

github_iconTop Results From Across the Web

Intermittent "Event loop stopped before Future completed."
Barring a bug in asyncio, the issue is likely caused by a call to loop.stop() hidden somewhere in the code base. You probably...
Read more >
Event Loop — Python 3.11.1 documentation
Running and stopping the loop. Run until the future (an instance of Future ) has completed. If the argument is a coroutine object...
Read more >
Event loop stopped before Future completed #96 - GitHub
What I think is happening is the app will exit after all windows attached to the app are closed (at least by default),...
Read more >
18.5.1. Base Event Loop — Python 3.6.3 documentation
Returns running status of event loop. Stop running the event loop. This causes run_forever() to exit at the next suitable opportunity (see there...
Read more >
Python run until complete - ProgramCreek.com
processEvents() # run loop one last time to process all the events if not future.done(): raise RuntimeError('Event loop stopped before Future completed.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found