alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* pyalsa with threads allowed for python (Py_BEGIN_ALLOW_THREADS & Py_END_ALLOW_THREADS)
@ 2008-05-17 16:40 ki.ber.kom.uni.st
  2008-05-19  6:45 ` Jaroslav Kysela
  0 siblings, 1 reply; 2+ messages in thread
From: ki.ber.kom.uni.st @ 2008-05-17 16:40 UTC (permalink / raw)
  To: ALSA development

i develop my app iterating ipython interactive sessions with pasting
the good code into files (which eventually being loaded back to
ipython sessions)...

for that kind of development i need pyalsa to run in python threads...
when i did (as it is now) alsaseq.Sequencer.receive_events(100) in
infinite loop of pyqt4 thread it always steal interaction from ipython
and it makes interaction unusable... it gets back every now and then
almost randomly and definitively not frequent enough to be usable..
hope this description explained enough of what's happening...

the solution was to make time.sleep(.001) at the end of while True:
loop... it took me several hours to find out the solution... i was
quite happy with the solution but my guru friends told me that's dirty
and i'm lame...

the other solution is in particular case of receive_events to put
Py_*_ALLOW_THREADS

    Py_BEGIN_ALLOW_THREADS;
    ret = poll(self->receive_fds, self->receive_max, timeout);
    Py_END_ALLOW_THREADS;

around poll...

this url should explain this strange phenomena (to me) to the real
programmers: http://www.python.org/doc/1.5.2/api/threads.html

in my case my programming guru akapav sort it out after couple of
minuts checking the code...

hope this is of some interest to pyalsa devs... i definitively would
need most of the functions being ready to run in threads....

thanx.. keep up the good work...

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: pyalsa with threads allowed for python (Py_BEGIN_ALLOW_THREADS & Py_END_ALLOW_THREADS)
  2008-05-17 16:40 pyalsa with threads allowed for python (Py_BEGIN_ALLOW_THREADS & Py_END_ALLOW_THREADS) ki.ber.kom.uni.st
@ 2008-05-19  6:45 ` Jaroslav Kysela
  0 siblings, 0 replies; 2+ messages in thread
From: Jaroslav Kysela @ 2008-05-19  6:45 UTC (permalink / raw)
  To: ki.ber.kom.uni.st; +Cc: ALSA development

On Sat, 17 May 2008, ki.ber.kom.uni.st wrote:

> the other solution is in particular case of receive_events to put
> Py_*_ALLOW_THREADS
> 
>     Py_BEGIN_ALLOW_THREADS;
>     ret = poll(self->receive_fds, self->receive_max, timeout);
>     Py_END_ALLOW_THREADS;

Added to our repository. Thanks.

					Jaroslav

-----
Jaroslav Kysela <perex@perex.cz>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-05-19  6:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-17 16:40 pyalsa with threads allowed for python (Py_BEGIN_ALLOW_THREADS & Py_END_ALLOW_THREADS) ki.ber.kom.uni.st
2008-05-19  6:45 ` Jaroslav Kysela

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).