wait_for_edge() raises "Error waiting for edge" in multi-threaded app
A Python module to control the GPIO on a Raspberry Pi
Brought to you by:
croston
Hello Ben,
In my application I have several threads and each one is calling
wait_for_edge() on it's own pin. It turns out that I cannot call
wait_for_edge() if another thread is also calling this method:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #!/usr/bin/python import RPi.GPIO as GPIO from threading import Thread GPIO.setmode(GPIO.BCM) GPIO.setup(14, GPIO.IN) GPIO.setup(16, GPIO.IN) def callback(): GPIO.wait_for_edge(14, GPIO.RISING) t = Thread(target=callback) t.daemon = True t.start() GPIO.wait_for_edge(16, GPIO.RISING) |
Error:
Traceback (most recent call last): File "./wait_for_edge.py", line 18, in <module> GPIO.wait_for_edge(16, GPIO.RISING) RuntimeError: Error waiting for edge
Is this a bug or by design?
RPi.GPIO version 0.5.11
Raspberry Pi B+
Raspbian Linux (/etc/debian_version=7.6)
This might be fixed in release 0.6.3. I need to add a test for this case.
I am seeing this behavior still in 0.6.3. Is there any kind of workaround?
Any update?
I use 0.7.0 and have the same problem.