How to force a thread to stop

Paul Boddie paul at boddie.org.uk
Thu Jul 27 09:22:27 EDT 2006


Paul Rubin wrote:
>
> Instead of using os.system, maybe you want to use one of the popens or
> the subprocess module.  For each ssh, you'd spawn off a process that
> does the ssh and communicates back to the control process through a
> set of file descriptors (Unix pipe endpoints or whatever).  The
> control process could use either threads or polling/select to talk to
> the pipes and keep track of what the subprocesses were doing.

For some insight into what you might need to do to monitor asynchronous
communications, take a look at the parallel/pprocess module, which I
wrote as a convenience for spawning processes using a thread
module-style API whilst providing explicit channels for interprocess
communication:

http://www.python.org/pypi/parallel

Better examples can presumably be found in any asynchronous
communications framework, I'm sure.

> I don't think you need anything as complex as shared memory for this.
> You're just writing a special purpose chat server.

Indeed. The questioner might want to look at the py.execnet software
that has been presented now at two consecutive EuroPython conferences
(at the very least):

http://indico.cern.ch/contributionDisplay.py?contribId=91&sessionId=41&confId=44

Whether this solves the questioner's problems remains to be seen, but
issues of handling SSH-based communications streams do seem to be
addressed.

Paul




More information about the Python-list mailing list