help with threads

Hendrik van Rooyen hendrik at microcorp.co.za
Fri Aug 7 03:38:54 EDT 2009


On Friday 07 August 2009 05:02:10 Michael Mossey wrote:
> Hello,

> My problem is that in some cases, the network thread appears to stop,
> while the main thread is doing a long computation.

Is this computation done in pure python or are you calling some
underlying thing in C?

I would be surprised if a pure python computation thread were to hog
the cpu  - have you been able to figure out what the computation thread is
actually doing when the hogging occurs?

> I'm hoping someone can give me a general idea what to read about. For
> example, under what conditions does a thread stop running? Can other
> threads "take priority"? Are there certain operations that block other
> threads (such as disk access)?

AFAIK python threads are all at the same level of priority, and the running
thread is interrupted every N python bytecode instructions, so what you are
experiencing should not happen.

Try to figure out, if you can, where the computation thread is spending
its time.

- Hendrik



More information about the Python-list mailing list