-
Notifications
You must be signed in to change notification settings - Fork 15
python3 lirc.nextcode() seems to block even when blocking set to False #2
Comments
To make matters more confusing, it seems to somehow be blocking all other threads in my python program as well. Every thread seems to be put on hold unless I hold down a button on the remote. I'm sure this isn't on purpose. |
There was a bug with the Thanks. |
I'll give it a try, thanks! edit: Um... still trying to figure out how to download the testing branch. I found a link to get a zip file... I'll figure it out soon... edit2: Looks like it is working. I need to play around in my program, remove my work arounds, to be sure but I think it is behaving the way I'd expect it to. |
To get the testing branch:
Also, Python can't really do threads: "In CPython, due to the Global Interpreter Lock, only one thread can execute Python code at once" |
Yeah, I'm using sleeps and loops to give other threads time to execute. While active, each thread should still be spending 95% of it's time sleeping, which gives the other threads time to poll their stuff and go back to sleep. The only lock I have is a split second when the led changes color. This should let it handle a bunch of inputs at once even if it hasn't had a chance to send all of the commands yet. I may try rewriting it another way later and see which works better in practice. |
Ok cool. I'll merge the change into master, thanks for your help. |
Wrote very short program to demonstrate this:
This should print "Looped!" every second, and also print the button pressed otherwise. But the program stops (is blocked) at the nextcode() line until a button is pressed. It then passes on the button, and a handful of zero length returns, then goes back to blocking.I've also tried with the separate "set_blocking" line. I can see in the code where it is supposed to set the O_NONBLOCK flag, so maybe it's a bug in LIRC? I'm really new to python, so if I'm misunderstanding something, just let me know please.
The text was updated successfully, but these errors were encountered: