communicate() is blocking. that's why i said you should start a thread or a timer or use select.
----------------------------------------------------------------- *Tomer Filiba* tomerfiliba.com <http://www.facebook.com/tomerfiliba> <http://il.linkedin.com/in/tomerfiliba> On Sat, Jan 28, 2012 at 14:15, Ido <[email protected]> wrote: > I might be wrong here, but the call to proc.communicate() would be > synchronous, so I could not terminate()/kill() it with a timeout (It would > wait unter .communicate would finish). > > This is what seems to happen in my testing. > > ------------------------------ > *From:* Tomer Filiba <[email protected]> > *To:* Ido <[email protected]> > *Cc:* rpyc <[email protected]> > *Sent:* Saturday, 28 January 2012, 13:47 > *Subject:* Re: problems with RPYC calling subprocess.Popen > > please use the mailing list to ask questions... > > anyway, you want to run a process on a remote machine and get back its > stdout/err? > just use the subprocess module, like so: > > c = rpyc.classic.connect("my-other-machine") > proc = c.modules.subprocess.Popen(["/the/program", "--and", "some", > "arguments"], stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = > subprocess.PIPE) > stdout, stderr = proc.communicate() > > you can then call proc.terminate() or kill() to terminate the program > after a certain timeout. > if it's on a posix machine, you can use select(), otherwise, start a > thread (see threading.Timer in the stdlib). > > ----------------------------------------------------------------- > > *Tomer Filiba* > tomerfiliba.com <http://www.facebook.com/tomerfiliba> > <http://il.linkedin.com/in/tomerfiliba> > > > > On Sat, Jan 28, 2012 at 13:31, Ido <[email protected]> wrote: > > Hi, > > I'm trying to use rpyc to run commands on remote servers. > I am interested in sending back STDOUT/ERR responses to the client, and > having the option of terminating the running command after a predefined > timeout. I care less if its run async or not. > > My problem is that Popen has blocking reads, and will also need to be > terminated manually ? (It seems that if I use rpyc.timeout, although the > client times out, the popen/command continues to run on the server). > > I'm not much of a python programmer, however this is my only need. > I also googled around, and tried hacking a fix myself, but was > unsuccessful. > > Can you please tell me what needs to be done ? (or maybe hack up a > solution yourself for me :) > > Toda. > > > > >
