Python threads

dj trombley worldwin at liii.com
Fri Dec 17 01:53:28 EST 1999


Emmanuel Pietriga wrote:

> The problem is that, even with time.sleep(???) in the eventListener
> thread, the other one (repainting thread) isn't allowed to execute very
> often (once every 4 sec., and in a very heratic way).
> 
> I have also tried to put one of the thread's code in the while1: pass of
> the main function. It behaves the same.
> I think the problem comes from the thread scheduler. But I don't know
> what to do!

You may want to try lowering the interval at which python checks to
switch threads.
This can be done with sys.setcheckinterval(<number>).  <number> is the
number of
python atomic instructions that get executed before a switch is
possible.  Keep in
mind that calls to C extensions are considered atomic, so they can
greatly affect this 
sort of performance.  

In my experience, sometimes it is worth it to run a seperate python
interpreter in another
process and use some sort of IPC.  Admittedly, the current state of
python threads leave something
to be desired with respect to this sort of issue, and others (the
per-exc frame signal thing, 
thread suspension, per-thread check intervals, etc).

-dj

Dave Trombley
<badzen at yifan.net>



More information about the Python-list mailing list