python - How to release GIL in subprocess.Popen.communicate() -


i have 2 threading.threads, , each calls:

p = subprocess.popen(...) o,e = p.communicate() 

it seems gil not released when calling p.communicate(). in above code, threads become pipelined, when first thread finishes, second can start , that's not desired behavior.

is there way wait on popen in way releases gil?

use multiprocessing module instead of threading.

look @ first sentence in introduction of https://docs.python.org/2/library/multiprocessing.html.

or, if still want use threads, not call communicate(), use stdin , stdout pipes. still have careful, because may inadvertly lock process way. happens, example, if try read process's stdout when there no data available. have know when data available, , how many bytes of available (this not polling).

p = subprocess.popen( ..., stdin=subprocess.pipe, stdout=subprocess.pipe ) p.stdin.write( ... ) n = 1 x = p.stdout.read(n)  # lock if less n bytes available           

Comments

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -