Threading issue in Python example

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]




I have read about the threading issues with using Python but I don’t quite understand
what I can do to properly synchronize the main in a simple script with, for example, the registration
state of a SIP account.  In trying to understand how to do it I have found that even the
simple Python demo at
will cause a seg fault due to the time.sleep() call.  Note that for the script to work you must
add import pjsua as pj and import time to it.  But that’s mainly all I did and of course I changed
the SIP registrar URI to my SIP proxy.  Oh, and I updated the print to be compatible with
python3.  Maybe running with python3 is an issue?  Anyway, if I take out the time.sleep

call then no seg fault.  But with it I get a seg fault.

I discovered this after frustrating hours trying to post a semaphore from the onRegState
callback and wait on the semaphore in the main thread.  I thought it was something to
do with the use of the semaphore but then removed that and tried just running with
the thread.sleep and to my surprise that was enough to cause the seg fault. 
Just making the one-line change to my script to comment out the call to thread.sleep
as below makes it register successfully with my proxy.


    acc = Account();


  # Here we don't have anything else to do..



The preceding works causes a seg fault

But the following does not and all works wonderfully:


    acc = Account();


  # Here we don't have anything else to do..

  # time.sleep(10);





Visit our blog:

pjsip mailing list

[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux