Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #21149

RE: Python - CGI-BIN - Apache Timeout Problem

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <scavanau@cisco.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'subject:Python': 0.05; 'prints': 0.07; 'subject:Apache': 0.07; 'url:py': 0.07; 'python': 0.08; 'scripts': 0.09; 'problem:': 0.09; 'subject:Problem': 0.09; 'output': 0.10; 'message-----': 0.12; '#python': 0.16; 'chris,': 0.16; 'chugging': 0.16; 'deadlock': 0.16; 'email name:chris': 0.16; 'err': 0.16; 'fires': 0.16; 'hangs': 0.16; 'proc': 0.16; 'timeout': 0.16; 'timeout.': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; 'loading': 0.18; 'switched': 0.18; 'seems': 0.20; 'cheers,': 0.20; 'apache': 0.21; 'cc:no real name:2**0': 0.21; 'header:In-Reply-To:1': 0.22; 'interface': 0.23; 'command': 0.24; 'fine': 0.24; 'hey': 0.24; 'suspect': 0.24; 'seconds': 0.26; 'cc:2**0': 0.26; 'code': 0.26; 'testing': 0.26; 'script': 0.28; 'sean': 0.29; 'problem': 0.29; 'print': 0.29; 'cc:addr:python.org': 0.29; 'pm,': 0.29; 'keeps': 0.30; 'chris': 0.30; 'error': 0.30; 'cc:': 0.31; 'url:library': 0.31; 'thanks': 0.32; 'fri,': 0.34; 'running': 0.34; 'something': 0.35; 'subject:': 0.35; 'url:python': 0.35; 'executing': 0.37; 'friday,': 0.37; 'but': 0.37; 'using': 0.37; 'received:128': 0.38; 'enough': 0.38; 'couple': 0.38; 'sent:': 0.38; 'open': 0.38; 'url:org': 0.39; 'except': 0.39; 'goes': 0.39; 'from:': 0.40; 'background': 0.40; 'skip:s 40': 0.40; 'quick': 0.61; 'your': 0.61; 'march': 0.61; '8bit%:23': 0.62; 'minutes': 0.64; 'website': 0.65; 'taking': 0.66; 'friends:': 0.67; 'received:171': 0.67; 'webpage': 0.67; '8bit%:100': 0.69; 'skip:\xc2 10': 0.74; 'dead': 0.77; '12:09': 0.84; 'advise,': 0.84; 'eventual': 0.84; 'hanging': 0.84; 'reply!': 0.84; 'still.': 0.84; 'wow': 0.84; 'wrong...': 0.84; 'by.': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=scavanau@cisco.com; l=3454; q=dns/txt; s=iport; t=1330722226; x=1331931826; h=mime-version:content-transfer-encoding:subject:date: message-id:in-reply-to:references:from:to:cc; bh=rvVP4xSirA0w0PugXLlocCBx2Mtw4RSyAhe9Mx4pTls=; b=ZA3C9ONPFIMrSuG3b6kG7cmr3LxjxLg17zI3WJqAA3j9Hhx+yXNLufjL +vrw2Pb0DtGt3Cms5qyiLp26yKfiE6R8RgojYi9zmq8FcYL3h4aO6uanx /sIZPcju2D/glzMwUNGL+dKB9lO8wxPbf67494O9wDNWTOO8KmP1XMm70 E=;
X-IronPort-Anti-Spam-Filtered true
X-IronPort-Anti-Spam-Result AgIFACs1UU+rRDoI/2dsb2JhbAA7CIU/rg94gQeBfQEBAQMBEgEQBAkERQUHBAIBBgIOAwQBAQMCBgYXAQICAgEBRAkIAQEEEwgah18EAQuhBQGMZYpBgS+IW4REM2MEiFCgBA
X-IronPort-AV E=Sophos;i="4.73,519,1325462400"; d="scan'208";a="34170263"
X-MimeOLE Produced By Microsoft Exchange V6.5
Content-class urn:content-classes:message
MIME-Version 1.0
Content-Type text/plain; charset="utf-8"
Content-Transfer-Encoding base64
Subject RE: Python - CGI-BIN - Apache Timeout Problem
Date Fri, 2 Mar 2012 13:05:29 -0800
In-Reply-To <CAMZYqRTXSHD9DnjVVj87vVVi21ePQyOaqjTYH6h=iQGDN2XULA@mail.gmail.com>
X-MS-Has-Attach
X-MS-TNEF-Correlator
Thread-Topic Python - CGI-BIN - Apache Timeout Problem
Thread-Index Acz4sj3DSw719Y2tSoyEJQggsDzPVwABX70w
References <6FC169072CBFF3409B6E74F50175A4650497A3F9@xmb-sjc-215.amer.cisco.com> <CAMZYqRTXSHD9DnjVVj87vVVi21ePQyOaqjTYH6h=iQGDN2XULA@mail.gmail.com>
From "Sean Cavanaugh (scavanau)" <scavanau@cisco.com>
To "Chris Rebert" <clp2@rebertia.com>
X-OriginalArrivalTime 02 Mar 2012 21:03:36.0805 (UTC) FILETIME=[EF849950:01CCF8B7]
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.354.1330722228.3037.python-list@python.org> (permalink)
Lines 45
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1330722228 news.xs4all.nl 6974 [2001:888:2000:d::a6]:45763
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:21149

Show key headers only | View raw


Hey Chris,

Thanks for your quick reply!  I switched my code to->

proc = subprocess.Popen(['/usr/local/bin/python', 'tests.py'], stdout=subprocess.PIPE)
out, err = proc.communicate()
print out
proc.stdout.close()

It still dead locked.  Interestingly enough When I did a #python tests.py on the command line even that was taking awhile to print out to the command line so I decided to restart my webserver... wow from mucking before something must have been running in the background still.  I got the script down to 2 seconds or so... 

Now it still works but faster when I do #python main.py it generates all the text to the command line but the website still hangs when I go to http://webserver/main.py... I am not sure what is going wrong... no error in the /var/log except for the eventual timeout after a couple minutes goes by.

-S

-----Original Message-----
From: chris@rebertia.com [mailto:chris@rebertia.com] On Behalf Of Chris Rebert
Sent: Friday, March 02, 2012 3:23 PM
To: Sean Cavanaugh (scavanau)
Cc: python-list@python.org
Subject: Re: Python - CGI-BIN - Apache Timeout Problem

On Fri, Mar 2, 2012 at 12:09 PM, Sean Cavanaugh (scavanau)
<scavanau@cisco.com> wrote:
<snip>
> 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 including
> the script.  The ‘core’ part of the script dumbed down to the lowest level
> is->
>
>         proc = subprocess.Popen(['/usr/local/bin/python', 'tests.py'],
> stdout=subprocess.PIPE)
>         output = 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

>         print output
>         proc.stdout.close()

As the docs advise, try using .communicate()
[http://docs.python.org/library/subprocess.html#subprocess.Popen.communicate
] instead:
    proc = subprocess.Popen(…)
    out, err = proc.communicate()
    print out

> When I open main.py and execute the script it just hangs… it seems to
> execute the script (I see pcap fires on the interface that I am testing on
> the firewall) but its not executing correctly… or loading the entire
> webpage…the 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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

RE: Python - CGI-BIN - Apache Timeout Problem "Sean Cavanaugh (scavanau)" <scavanau@cisco.com> - 2012-03-02 13:05 -0800

csiph-web