PJSUA Python Flow Control

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

 



Hi JP,

On 2012-02-03 13:21, JP Viljoen wrote:
> On Tue, Jan 31, 2012 at 5:44 PM, JP Viljoen <jp at neology.co.za
> <mailto:jp at neology.co.za>> wrote:
>     I'm putting together a script to make outbound phonecalls from a
>     headless Linux host, so it will essentially be running unmanned and
>     playing back a wav file. I loosely based my work off of the
>     simplecall.py sample which is included in the pjproject-1.12 tarball
>     (which was the stable version at the time of download).
>
>     My problem is that I'm not entirely sure how to handle waiting
>     around when running in an automated way. Presently I can dial out
>     and wait before terminating (based on a readline, as per the
>     original simplecall.py), but this of course will not work during
>     automatic operation. An inspection of the documentation indicates
>     that I will receive call disconnection information in a
>     CallCallback.on_state(), and I have put my teardown code there
>     accordingly

Event callbacks run normally in a worker thread (not the main thread).

If you do not want to use threading, I think you can use (I didn't test 
this though):

lib.start(with_thread=False);
while True:
     time.sleep(0.01);
     lib.handle_events();

(see the http://www.pjsip.org/python/pjsua.htm for help on lib.start() 
and lib.handle_events())

If you want to use threading, there are many ways in which you can 
communicate from the callback to the main thread that the main thread 
should exit the main application loop and shut down the application.

>     but when running I get something immediately bombing
>     because a lib instance is found as NoneType (which has no destroy(),
>     and thus an AttributeError exception is thrown). If necessary, I can
>     provide the sourcecode of what I've got so far.
>
> No-one who can help with this?

 From you description of the error you got I gather you have an error in 
your Python code; please send your code (i.e. a minimal stand-alone 
Python script demonstrating the problem) and the output of the program 
as you ran it if you want someone to look at it!

Kind regards,

Bram



[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