Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'skip:[ 20': 0.04; 'output': 0.05; '"""': 0.07; 'completeness': 0.07; 'problem?': 0.07; 'skip:` 10': 0.07; 'subject:skip:s 10': 0.07; 'received:155': 0.09; 'solution,': 0.09; 'subject:instance': 0.09; 'python': 0.11; 'argument,': 0.16; 'blocks': 0.16; 'disclaimers': 0.16; 'disclaimers,': 0.16; 'forty': 0.16; 'from:addr:jpmorgan.com': 0.16; 'googled': 0.16; 'received:155.180': 0.16; 'received:155.180.234': 0.16; 'received:159': 0.16; 'received:159.53': 0.16; 'received:exchad.jpmchase.net': 0.16; 'received:jpmchase.com': 0.16; 'received:jpmchase.net': 0.16; 'returncode': 0.16; 'securities,': 0.16; 'tempfile': 0.16; 'terminate.': 0.16; 'url:disclosures': 0.16; 'url:jpmorgan': 0.16; 'issue.': 0.22; 'sort': 0.25; "i've": 0.25; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; 'tim': 0.29; "i'm": 0.30; 'code': 0.31; 'that.': 0.31; 'follows': 0.31; 'option.': 0.31; 'pipe': 0.31; 'skip:s 70': 0.31; 'received:169.254': 0.32; 'option': 0.32; 'url:python': 0.33; 'could': 0.34; 'johnson': 0.35; 'but': 0.35; 'accuracy': 0.36; 'found.': 0.36; 'done': 0.36; 'charset:us-ascii': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'should': 0.36; 'received:169': 0.37; 'so,': 0.37; 'url:library': 0.38; 'handle': 0.38; 'to:addr :python-list': 0.38; 'little': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'enough': 0.39; 'how': 0.40; 'solve': 0.60; 'information,': 0.61; 'such': 0.63; 'more': 0.64; 'purchase': 0.65; 'managing': 0.66; 'brain': 0.68; 'covers': 0.68; 'subject': 0.69; 'legal': 0.71; 'surprise': 0.74; 'sale': 0.75; 'topic,': 0.81; '2.7.1': 0.84; 'examples.': 0.84; 'received:169.254.8': 0.84 X-DKIM: OpenDKIM Filter v2.1.3 sf1.jpmchase.com r7TInnIp015113 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpmorgan.com; s=smtpout; t=1377802189; bh=uf1U3FS7qVASKE/2rPS/GTgNaxxFDyJwDdITHdJOOU8=; h=From:To:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:content-transfer-encoding:MIME-Version; b=OrRzWNGDRUmK2MyweTVfkd37cyGkz0dpqREYb2hmUGkWfovMBeVhLDX9qfpjhEBjZ A7vg5iWSJi48iYSAuKRtQoMvD4l+RDMm+ie7DWmnLe6MfAI3OMheQQGDupVLEavBAD Rl4oA4WZtfDk5K8QZpfseXiff2PLTgAGr+P7rapk= X-AuditID: a97c8569-b7ff58e0000028c7-a4-521f97cc0568 From: "Prasad, Ramit" To: Tim Johnson , Python ML Subject: RE: subprocess.Popen instance hangs Thread-Topic: subprocess.Popen instance hangs Thread-Index: AQHOpOc+BV20YACdb0m8NL9gxfNj+pmshYMg Date: Thu, 29 Aug 2013 18:49:47 +0000 References: <20130829183418.GE414@mail.akwebsoft.com> In-Reply-To: <20130829183418.GE414@mail.akwebsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.67.79.47] Content-Type: text/plain; charset="us-ascii" content-transfer-encoding: quoted-printable MIME-Version: 1.0 X-DLP-FWD: Yes X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJKsWRmVeSWpSXmKPExsWy0tXaRPfMdPkgg6sLjSyOtF5jtej4O43F gcmj7cAfJo8X89+wBTBFNTDaJObl5ZcklqQqpKQWJ9squWQWJ+ckZuamFinoKngV5OYXpSfm 6SXn5yopZKbYKpkoKRTkJCan5qbmldgqJRYUpOalKNlxKWAAG6CyzDyF1Lzk/JTMvHRbJc9g f10LC1NLXUMlu5CMzGKF1NzEzByFhI3sGbf3n2It2MNTcfXFTKYGxk+cXYycHBICJhLNt/8x Q9hiEhfurWfrYuTiEBI4zCixfeVbJgjnIKPEqr/9UJlNjBLN/T/YQFrYBAwljp99wg5iiwi4 S8xa9gpoFAeHsICOxKGlTBBhXYl5D06xQNhGEpP2vWEFsVkEVCVOrP8HZvMKhEj8OXWCBaRV SMBU4vA/ZZAwp4CZxMWfHWCbGIGO+35qDdhIZgFxiVtP5jNBHC0gsWTPeagHRCVePoYYKSEg L/Fiyks2iHodiQW7P0HZ2hLLFr5mhlgrKHFy5hOotWoS+9bbgpgSAnwS29uqJzBKzEKybBaS QbOQDJqFZNACRpZVjJLFuekZxnrFZUV6pcV6WQW5yRmJxal6eaklmxhBKaamNXMH4+LltocY BTgYlXh4LcLkg4RYE8uKK3MPMUpwMCuJ8LIHHQkU4k1JrKxKLcqPLyrNSS0+xFgFDLKJzFKi yfnA9JdXEm9obGZhYGpqaGBhaGRCFWElcd6ZXdJBQgLpwISanZpakFoEs5yJg1OqgdE7Zru2 szp/r8fM3Kv6M2QO62jsLZ8h2Zu85scce+HKo7v6W1eXBi6IkK+X37Ex6MUd7UPPeQRTZuyc efTvtX/lf1Ldvn+LFTB02Raw9JXgvADz/rvPf+vl9vw5Uusq/uD3selPph9+OeFDD4fBSh2p 9V0zPs/W38+y8IUi/8fTLAk7GvoXOGorsRRnJBpqMRcVJwIAJbw65IwDAAA= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 59 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1377803842 news.xs4all.nl 15917 [2001:888:2000:d::a6]:42376 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:53252 Tim Johnson > using Python 2.7.1 on OS X 10.7.5 > > I'm managing a process of drush using an instance of subprocess.Popen > > The process has a '--verbose' option. When that option is passed as > part of the initializer `args' argument, the process will hang. > > It should be no surprise as drush output with the --verbose option > can be _extremely_ verbose, and I can do without it, but I would > like to learn how to handle it. I've googled this topic, but my poor > little brain is yet to sort out all of the content found. > > ## my relevant code follows : > p =3D subprocess.Popen(args,stderr=3Dsubprocess.STDOUT,stdout=3Dsubprocess= .PIPE) > ## wait() is 'forever' if '--verbose' used > exit_status =3D p.wait() > output =3D p.stdout.read() > ## done > > I 'suspect' that using a tempfile may be the solution, if so, I > could use some examples. > > thanks > -- > Tim > tim at tee jay forty nine dot com or akwebsoft dot com > http://www.akwebsoft.com > -- I think the documentation covers your issue. """ Popen.wait() Wait for child process to terminate. Set and return returncode attribute= . Warning: will deadlock when using stdout=3DPIPE and/or stderr=3DPIPE and= the child process generates enough output to a pipe such that it blocks waiting fo= r the OS pipe buffer to accept more data. Use [Popen.]communicate() to avoid t= hat. """ From http://docs.python.org/2/library/subprocess.html#subprocess.Popen.w= ait Does switching to `p.communicate()` solve your problem? ~Ramit This email is confidential and subject to important disclaimers and conditio= ns including on offers for the purchase or sale of securities, accuracy and= completeness of information, viruses, confidentiality, legal privilege, and= legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclo= sures/email.