fsmeraldi / bleakheart

An asynchronous BLE Heart Monitor library with support for additional data from Polar monitors (ECG, accelerometers, etc)
Mozilla Public License 2.0
10 stars 9 forks source link

AsyncIO Windows 10 specific issue #4

Closed HufflyCodes closed 4 months ago

HufflyCodes commented 5 months ago

When adapting BleakHeart to run on Windows 10 I ran into an issue described here and it is thankfully a simple fix that was already discovered by AsyncIO.

By adding in the main loop:

if 'win32' in sys.platform:
# Windows specific event-loop policy & cmd
        asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())
        cmds = [['C:/Windows/system32/HOSTNAME.EXE']]

The issue is resolved!

fsmeraldi commented 4 months ago

Thank you very much, and apologies for the late reply. I will include this in the next update. Is the cmds variable actually needed? It seems to be specific to the example you linked.

Also: on Linux, I am getting good results running with uvloop - it seems to be a bit more snappy, though I have not measured it. You may want to try it

HufflyCodes commented 4 months ago

My apologies you are correct the cmds variable is not needed unless you wanted to have an automatic detection of which operating system you are using. Thank you for the heads up on uvloop! Sadly they do not support win10 at the moment but when I switch to my Linux setup I will give it a try. The quick responsiveness is perfect as I plan on running this on an RPi so that will be needed.

fsmeraldi commented 4 weeks ago

Just a note to say that ProactorEventLoop seems now to be the default on Windows https://docs.python.org/3.11/library/asyncio-platforms.html