windows - Python syntax error with subprocess.poll -


I went to the issue today, and managed to repeat it with this small script, on which Python 2.7.6 There is a win7x64 machine, but this problem has come too much by using portable dragon on platforms of various windows in the script

  Upproos import pipes, import from time to sleep Popen from class test (object): Def run_cmd (self, CMD, wait = True): P = Papen (CMD, staden = pipe, c Tdaut = pipe, Stederr = pipe) if the wait: p.com Muket () returns PA: Return P Diif some (self): P = Self Krun_cmd ( 'Notepad' Wait = False) Import PDB; Pdb.set_trace () while not p.poll (): printed 'process still operates' sleep (10) print p. Writecode, p. Studout, P.Studder DEF APEL (Self): P = self.run_cmd ('Notepad') Print P RatterCode, p. Studout, pstderr t = test () t. SAMATLS (T) some. ()   

What happens, some have started a process in the foreground and the Python script is waiting to exit it and print the return code, standout and stadder, but the second In the call, some process has been started, but whether you end the process or not, the dragon lives in the loop. I then added PDB step and this is output,

  & gt; & Gt; & Gt; T.something () & gt; & Lt; Stdin & gt; (12) Some () (PDB) Print P & lt; Subprocess.open object 0x0000000002D73D68 & gt; (Pdb) p.poll () *** Syntax Error: Syntax Error ('invalid syntax', ('& lt; string'; 1, 1, '.poll ()')) (PDB)   

The choice is open, no one returns, the process is open, and when it is done, returning / returning code always does not return any returns, only with additional output in the debugger. The process has started and works in the expected form. What I am doing with any idea which is the process of subprime. Can 'invalid syntax' be returned? This is strange, because it does not throw an exception, it is never updated to return the return code and p. Any attempt to print PID, P.T.IN., PTTDT produces the same error, but then, only in the debugger.

I'm not sure what is SyntaxError in PDB, but it is:

  while not p.poll (): print 'process is still going on' sleep (10)   

Enter an infinite loop if Return code is p of 0, which is a good possibility.

Use it instead:

  while p.poll () is none: print 'process is still going on' sleep (10)    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -