Questions about threads

LeoDeBeo leodebeo at hotmail.com
Tue Aug 28 09:10:53 EDT 2001


A wrote:

> 
> 
> Hi,
> Can anybody please answer my questions?
> 
> 1. In my application  I need one function to run in threads. The
> number of threads is chosen by user and numbers of threads can
> not be higher at one time.
> This function writes to a file also.How can I prevent other threads
> from writing to this file when the file is open by another thread ?
> 
> 2. How can one process control another? For example: my
> program tries to connect to a server over phone.  I want  to cancel
> dial up connection if there is timeout. How can that be done in
> Python?
> 
> Thank you very much for help.
> Ladislav
> 
> 
> 
> 
> 
for the serializing of the file operations: use locks.
look in the library reference for the thread module
to control another process: you'll have to start your program from within 
python, so that you can acquire the process id. With that information you 
can do anything with the running process. there are various solutions: run 
the program with 'popen' or 'system'-call or use a fork and exec call




More information about the Python-list mailing list