Menu

#103 wait_for_edge() raises "Error waiting for edge" in multi-threaded app

New
None
Medium
Patch
2020-02-09
2015-04-23
No

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)

1 Attachments

Discussion

  • Ben Croston

    Ben Croston - 2016-10-30

    This might be fixed in release 0.6.3. I need to add a test for this case.

     
  • Ray Cox

    Ray Cox - 2017-01-08

    I am seeing this behavior still in 0.6.3. Is there any kind of workaround?

     
  • Jeff Chua

    Jeff Chua - 2017-11-07

    Any update?

     
  • ssph

    ssph - 2020-02-09

    I use 0.7.0 and have the same problem.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.