[PATCH] python: fix Popen.wait() deadlock issue

joeg at catalyst.net.nz joeg at catalyst.net.nz
Mon Oct 2 21:06:27 UTC 2017


Hi everyone,
I am Joe Guo, a new Samba developer from Catalyst IT, New Zealand.

In `python/samba/tests/__init__.py` file,  both `check_exit_code` and
`check_output` used `Popen.wait()` for command line output.
This will cause deadlock if the output is too large (for example, more
than 64k).

The issue is documented in Python official document at:
https://docs.python.org/2/library/subprocess.html#subprocess.Popen.wait

I created 2 patches for this issue.
0001 is the proof.  I added a python script to generate large output and
a known failed test case.
0002 is the fix. I use `communicate` instead of `wait` to avoid the
deadlock issue.


Cheers,
Joe Guo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-python-add-a-failed-test-to-show-Popen-deadlock.patch
Type: text/x-patch
Size: 7857 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20171003/dbb71185/0001-python-add-a-failed-test-to-show-Popen-deadlock.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-python-use-communicate-to-fix-Popen-deadlock.patch
Type: text/x-patch
Size: 2442 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20171003/dbb71185/0002-python-use-communicate-to-fix-Popen-deadlock.bin>


More information about the samba-technical mailing list