Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.05; 'prints': 0.07; 'subject:Apache': 0.07; 'scripts': 0.09; 'problem:': 0.09; 'subject:Problem': 0.09; 'output': 0.10; 'chugging': 0.16; 'deadlock': 0.16; 'err': 0.16; 'fires': 0.16; 'proc': 0.16; 'timeout.': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; 'loading': 0.18; 'seems': 0.20; 'cheers,': 0.20; 'cc:no real name:2**0': 0.21; 'header:In-Reply-To:1': 0.22; 'interface': 0.23; 'command': 0.24; 'fine': 0.24; 'suspect': 0.24; 'received:209.85.220': 0.25; 'cc:2**0': 0.26; 'code': 0.26; 'testing': 0.26; 'script': 0.28; 'message-id:@mail.gmail.com': 0.29; 'sean': 0.29; 'print': 0.29; 'cc:addr:python.org': 0.29; 'pm,': 0.29; 'keeps': 0.30; 'chris': 0.30; 'error': 0.30; 'url:library': 0.31; 'fri,': 0.34; 'url:python': 0.35; 'executing': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'using': 0.37; 'received:209.85': 0.38; 'open': 0.38; 'url:org': 0.39; 'received:209': 0.39; 'skip:s 40': 0.40; 'header:Received:6': 0.61; '8bit%:23': 0.62; 'friends:': 0.67; 'webpage': 0.67; '8bit%:100': 0.69; 'skip:\xc2 10': 0.74; '12:09': 0.84; 'advise,': 0.84; 'hanging': 0.84; 'sender:addr:chris': 0.84 Received-SPF: pass (google.com: domain of chris@rebertia.com designates 10.52.91.82 as permitted sender) client-ip=10.52.91.82; Authentication-Results: mr.google.com; spf=pass (google.com: domain of chris@rebertia.com designates 10.52.91.82 as permitted sender) smtp.mail=chris@rebertia.com; dkim=pass header.i=chris@rebertia.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=knVJEjVZp+g0F+nLYmdhDY/bSRhyo9UG6qO0mUDXw0g=; b=cZd9+8io1cfg2Jr8e+NpNb9rSOYTNu6zrMc2VLXcQTbA22FSIqHPoW71HLc1s2gJ88 yb81BCnw5MqCwaXd/cGO62qxq1v6+GB8yglb7EWyxQNC2T7k6aoWqkYlfByeNGI3Urb0 GUV/KTrQIQwm9Y0OivSR3sj+4BwRM8cSVC6wM= MIME-Version: 1.0 Sender: chris@rebertia.com In-Reply-To: <6FC169072CBFF3409B6E74F50175A4650497A3F9@xmb-sjc-215.amer.cisco.com> References: <6FC169072CBFF3409B6E74F50175A4650497A3F9@xmb-sjc-215.amer.cisco.com> Date: Fri, 2 Mar 2012 12:22:41 -0800 X-Google-Sender-Auth: TzF2zaA_yUr1dGU14JBpt66y3EU Subject: Re: Python - CGI-BIN - Apache Timeout Problem From: Chris Rebert To: "Sean Cavanaugh (scavanau)" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQnMRnxDUObhrUltDlRWxyrtVraedR9KB4pVZwkQbB5f05uq+P8+htHR+9wBrQGuruRYm2jo Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 48 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1330719764 news.xs4all.nl 6954 [2001:888:2000:d::a6]:55217 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:21147 On Fri, Mar 2, 2012 at 12:09 PM, Sean Cavanaugh (scavanau) wrote: > THE PROBLEM: > > When I execute the scripts from the command line (#python main.py) it > generates it fine (albeit slowly), it prints all the html code out includ= ing > the script.=C2=A0 The =E2=80=98core=E2=80=99 part of the script dumbed do= wn to the lowest level > is-> > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 proc =3D subprocess.Popen(['/u= sr/local/bin/python', 'tests.py'], > stdout=3Dsubprocess.PIPE) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 output =3D proc.stdout.read() Note the red warning box about possible deadlock with .stdout.read() and friends: http://docs.python.org/library/subprocess.html#popen-objects > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 print output > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 proc.stdout.close() As the docs advise, try using .communicate() [http://docs.python.org/library/subprocess.html#subprocess.Popen.communicat= e ] instead: proc =3D subprocess.Popen(=E2=80=A6) out, err =3D proc.communicate() print out > When I open main.py and execute the script it just hangs=E2=80=A6 it seem= s to > execute the script (I see pcap fires on the interface that I am testing o= n > the firewall) but its not executing correctly=E2=80=A6 or loading the ent= ire > webpage=E2=80=A6the webpage keeps chugging along and eventually gives me = an error > timeout. The hanging makes me suspect that the aforementioned deadlock is occurring. Cheers, Chris -- http://chrisrebert.com