[bug] Python samples "registration.py" race-condition

RK
Roland Koebler
Sun, Dec 18, 2016 12:35 AM

Hi,

I would like to report a bug in pjsip-apps/src/python/samples/registration.py:

There is a race-condition when waiting for the registration to finish.
The reason is, that the semaphore is created in wait, which may be too
late.

Demo:
add "time.sleep(2)" between acc.set_callback(acc_cb) and acc_cb.wait():

...
try:
...
acc_cb = MyAccountCallback(acc)
acc.set_callback(acc_cb)
time.sleep(2)
acc_cb.wait()
...

Solution: Create the semaphore before, e.g. in MyAccountCallback.init.

I've attached a patch.

thanks,
Roland

Hi, I would like to report a bug in pjsip-apps/src/python/samples/registration.py: There is a race-condition when waiting for the registration to finish. The reason is, that the semaphore is created in wait, which may be too late. Demo: add "time.sleep(2)" between acc.set_callback(acc_cb) and acc_cb.wait(): ... try: ... acc_cb = MyAccountCallback(acc) acc.set_callback(acc_cb) time.sleep(2) acc_cb.wait() ... Solution: Create the semaphore before, e.g. in MyAccountCallback.__init__. I've attached a patch. thanks, Roland