Bug#656137: readme.txt: asynchronous usage is a misleading lie
enrico at debian.org
Mon Jan 16 19:53:06 UTC 2012
in readme.txt there is an entry called "Asynchronous Usage", which shows
how to integrate PyAsterisk in a select-based event loop.
That bit leads you to believe that PyAsterisk can work in an
asynchronous environment like Twisted or Tornado. In fact, looking at
the code, that is most sadly untrue:
- Asterisk.Manager reads from the file descriptor using readline():
this blocks the main loop indefintiely, until a newline is read. If
the connection to asterisk hangs (say, network goes down) halfway
through a reply, goodbye event loop.
- Actions are synchronous. After sending a command to asterisk, a
readline() is issued right away. Again, this blocks the event loop
until asterisk replies, if it ever does.
So, the only way to integrate PyAsterisk in a select loop is to fork a
child process and run select on a pipe to it.
You would wish that an upstream who puts such comments in the code
actually knew what they were doing:
if line.startswith('ActionID: '):
# Asterisk is a pile of shite!!!!!!!!!
packet.ActionID = line[10:]
Not that they aren't right, of course :)
-- System Information:
Debian Release: wheezy/sid
APT prefers testing
APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Kernel: Linux 3.1.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages python-asterisk depends on:
ii python 2.7.2-9
ii python-support 1.0.14
python-asterisk recommends no packages.
python-asterisk suggests no packages.
-- no debconf information
More information about the Pkg-voip-maintainers