Ticket #3260 (closed defect: Fixed)
Need to call communicate() on subprocess objects before calling wait
| Reported by: | jstevens | Owned by: | jstevens |
|---|---|---|---|
| Priority: | 3 - Medium | Milestone: | zenoss-2.3 |
| Component: | All | Version: | 2.2.0 |
| Keywords: | zenoss-2.2.1-verified | Cc: | |
| Community Patch Attached: | Deployed @ Customer: | ||
| Installer: | Maintenance Target: | ||
| Specific ZenPack: | Maintenance Status: | ||
| Documentation Note?: | Not required | Regression: |
Description
zenpack --install was hanging on me when installing certain zenpacks. The code in ZenPackCmd.py was calling p.wait() right after p = subprocess.Popen(...., stdout=subprocess.PIPE,...) The problem is that the output buffer was filling up and the process was hung waiting for the buffer to be read while ZenPackCmd was waiting for the process to finish. A little googling led to this discussion:
http://bugs.python.org/issue1606
Basically we need a p.communicate() call prior to the p.wait() call. This is essential when using stdout/stdin=subprocess.PIPE when any lengthy output could occur. We should probably get in the habit of doing this everywhere we use p.wait() however.