Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
432 views
in Technique[技术] by (71.8m points)

unit testing - Pythons 3.8.2 subprocess.poll( ) hangs after being called 40 or 50 times

I just upgraded to MacOS 11.2 which now uses Python 3.8.2. My test suite guarantees that printed output prints as the output is sent to the console by using the code snippet below. As verified by the print xxx or print yyy statements the code hangs after roughly 50 Unit Tests. This code has been working for roughly 4 years and of course was working just prior to the 11.2 system upgrade. Any ideas for work arounds would be appreciated.

print( '
running: ' + curFilePath.split('/')[-1] + ': ' + str(curVer))
p = subprocess.Popen(fullCMD, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

while True:     # Print output as it sent to console
    print( 'xxx' )
    nextline = p.stdout.readline().decode()
    if nextline == '' and p.poll() is not None:
        print( 'yyy' )
        break
    sys.stdout.write(nextline)
    sys.stdout.flush()

print( 'completed: ' + curFilePath.split('/')[-1] )
question from:https://stackoverflow.com/questions/66052620/pythons-3-8-2-subprocess-poll-hangs-after-being-called-40-or-50-times

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...