-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Writing to characteristic values from outside the event loop #5
Comments
Run manager.run() in another thread or process, then you can stop it with manager.stop(). |
Did you actually try that? I did. It works but has some odd side-effects like the thread running the manager then receiving exceptions like ctrl-c and not the main thread anymore. I think a more detailed example would sure be helpful. |
i tried running it in another thread as well: unfortunately i wasn't able to stop it then. any idea, what i am doing wrong? |
Yeah, I tried it and didn't have any problems. https://gist.github.com/swojo/2b9b45cdd3bc744e28f7a2fbe885eace |
Thanks a lot. But as commented in your example i still see the manager thread receiving the ctrl-c and not the main thread. |
I see this on two different ubuntu x86 machines and on a raspberry pi. On what kind of machin does this work for you? |
As commented below the gist I can't even stop it with Ctrl+C. It takes a few seconds and throws another exception.. |
If i replace the call to manager.run() by something trivial like a time.sleep() then the exception handling works as expected. So manager.run() somehow influences all this. |
The closest thing i could come up with is this: But it e.g. requires the main thread to actively check for the manager thread to be still alive. Here someone describes exactly the same problem: |
This one also describes the same problem: |
Thank you very much. This solves the Issue. Now ctrl + C does not stop the Device Manager Thread anymore but raises a KeyboardInterrupt in the Main Thread as it is supposed to. |
I'm not sure how to make use of the event loop properly:
I would like to use the GATT SDK inside a flask server. When a http request is sent to the server I would like to write a value to a characteristic (by handle). But how can I access the DeviceManager or even start / stop it once it is running forever?
The text was updated successfully, but these errors were encountered: