question on multithreading, pipes

J

Jean-Yves Nief

hello,

I have written a script which is performing some tasks in
multithreading mode: the main thread is opening a connection to a
distant server and all the threads that I start will have to perform
actions on the remote server using the connection initiated by the main
thread. At first sight, the only way I could achieve that in a proper
manner (ie without having to open a connection to the remote server in
every single thread and close it at the end of the thread) would be to
use a pipe that I would use in all the threads, for example:
* main thread:
fw, fr = os.popen2('/bin/ksh')
fw.write('Sinit')
etc...
* other threads:
fw.write('perform action')
etc...

but if I do that, I need to queue the events, which means I have to
serialize the jobs perform by the threads, which is clearly not what I
want as I am using threads :)
so my question is: how could I get around this without giving up
multithreading ?
any help appreciated.
thanks,
JY
 
A

Aahz

but if I do that, I need to queue the events, which means I have to
serialize the jobs perform by the threads, which is clearly not what I
want as I am using threads :)
so my question is: how could I get around this without giving up
multithreading ?

Use a separate thread just to communicate with the remote server. This
still causes some serialization, but at least everything else is
independent.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top