-
Notifications
You must be signed in to change notification settings - Fork 25
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
[BUG] No current event loop in thread "Dummy-1". #289
Comments
Thanks for the bug report! The root of the problem is an unfortunate design choice made by the Kuando engineering team: the Busylight family of lights will quiesce if they don't receive a keep-alive packet. This means if you turn the light on and it doesn't receive a keep alive it will turn off. To normalize it's behavior with the rest of the supported lights (turn it on and it stays on until commanded off), I added asyncio support that would schedule a keep alive task to write to the device every seven seconds. The error makes sense, there isn't an async event loop running. A workaround for this is using the I'll revisit this code and see what I can do for the use-case you've presented. I can at least catch those exceptions and issue some better guidance to users. |
Wow, I didn't expect a reply so fast, thanks! I somehow managed to get the script working using the Thank you for clarifying the asnycio functionality, I would like a bit more control over the duration of the on-signal (it is currently on for around 25sec), but this is rather a nice-to-have-feature atm. |
Ok, after coffee (and really reading the stack trace you so helpfully provided) I have a better idea of what broke but I'm not sure how to fix it yet. The class File "/usr/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 'Dummy-1'. This is telling me that gstreamer is running your callback code in a thread, called "Dummy-1", and my call to |
…kableMixin As I understand it, when lights are activated in a thread other than the main thread there is not a default async event loop available and asyncio.get_event_loop raises a RuntimeError. I've modified the property TaskableMixin.event_loop to catch RuntimeError and create an event loop.
@robbyfrt I know this issue has languished for a while without any movement. I think I have a fix that addresses this bug and it would be great if you could test it to confirm that it works. The branch with the fix can be installed via $ python3 -m pip install git+https://github.com/JnyJny/busylight@fix/async I'll work on a test to add to the test suite to confirm that this works. |
@JnyJny Hello. I am using the LightManager with the Kuando Omega and applying effects using the apply_effect method. When i use the LightManager is seems to block the main thread. Is there any way around this to apply an effect without blocking the main thread but keeping the effect alive? Any info would be appreciated. Thank you. |
@isaaca26 In a perfect world, it shouldn't be blocking the main thread. To be honest this is the first non-toy async code I've written and it could probably use a re-write. It's kind of on the back burner right now but I'm happy to accept pull requests :) |
@isaaca26 if you could provide a test case or example of the code where you see the hang that would be very helpful to me. |
Software Versions:
General Type of Problem
Describe the Problem
So a simple script works great:
However, using this simple class in a more complex software however returns the error shown below.
I am calling light.on() inside a callback function of a gstreamer pipeline, which was written using python bindings. I have no idea how gstreamer itself generates its threads. I am using it inside a callback similar to this: deepstream_test_1.py -Line 71
It may be easier for me to use lower level functionality for simply turning the light on for some time, but I am unsure where to start in your repo.
Use Case: I simply want to turn my busylight on when my script hast detected some activity. Your api seemed quite straighforward for that.
Expected Behavior
What you expected to happen.
Error Output
The text was updated successfully, but these errors were encountered: