[Tutor] Questions about threads

Ignacio Vazquez-Abrams ignacio@openservices.net
Tue, 28 Aug 2001 09:39:20 -0400 (EDT)


On Tue, 28 Aug 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 writting to this file when the file is open by another thread ?

Use a threading.Lock or treading.Semaphore to control access to it.

> 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?

It depends on the process. If it's pppd, then sending it a SIGHUP should do.

> Thank you very much for help.
> Ladislav

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>

_______________________________________________
ActivePython mailing list
ActivePython@listserv.ActiveState.com
http://listserv.ActiveState.com/mailman/listinfo/activepython