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


Groups > comp.lang.python > #21150

RE: Python - CGI-BIN - Apache Timeout Problem

Return-Path <scavanau@cisco.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; ':-)': 0.06; 'prints': 0.07; 'subject:Apache': 0.07; 'python': 0.08; 'scripts': 0.09; '(it': 0.09; '(rather': 0.09; 'finishes': 0.09; 'firewall': 0.09; 'problem:': 0.09; 'subject:Problem': 0.09; 'used)': 0.09; 'output': 0.10; 'message-----': 0.12; 'library': 0.13; 'anyone?': 0.16; 'chugging': 0.16; 'deadlock': 0.16; 'email name:chris': 0.16; 'err': 0.16; 'fires': 0.16; 'proc': 0.16; 'timeout': 0.16; 'timeout.': 0.16; 'cc:addr:python-list': 0.16; '(i.e.': 0.17; 'wrote:': 0.18; 'loading': 0.18; 'seems': 0.20; 'cheers,': 0.20; 'apache': 0.21; 'cc:no real name:2**0': 0.21; 'maybe': 0.21; 'header:In-Reply-To:1': 0.22; 'interface': 0.23; 'command': 0.24; 'fine': 0.24; 'hey': 0.24; 'hopefully': 0.24; 'suspect': 0.24; 'cc:2**0': 0.26; 'code': 0.26; 'testing': 0.26; 'all,': 0.27; 'script': 0.28; 'sean': 0.29; 'problem': 0.29; 'print': 0.29; 'cc:addr:python.org': 0.29; 'pm,': 0.29; 'keeps': 0.30; 'ran': 0.30; 'threads.': 0.30; '(the': 0.30; 'chris': 0.30; 'error': 0.30; 'cc:': 0.31; 'url:library': 0.31; 'thread': 0.32; 'does': 0.32; 'sort': 0.33; "won't": 0.33; 'fri,': 0.34; 'test': 0.34; 'subject:': 0.35; 'url:python': 0.35; 'two': 0.36; 'executing': 0.37; 'friday,': 0.37; 'but': 0.37; 'using': 0.37; 'could': 0.38; 'some': 0.38; 'doing': 0.38; 'think': 0.38; 'sent:': 0.38; 'open': 0.38; 'url:org': 0.39; 'suggestions': 0.39; 'everyone': 0.39; 'from:': 0.40; 'skip:s 40': 0.40; 'march': 0.61; '8bit%:23': 0.62; 'internet': 0.64; '(after': 0.67; 'friends:': 0.67; 'it)': 0.67; 'received:171': 0.67; 'webpage': 0.67; 'receive': 0.68; 'traffic': 0.68; 'friday': 0.68; '8bit%:100': 0.69; 'skip:\xc2 10': 0.74; '12:09': 0.84; 'advise,': 0.84; 'hanging': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=scavanau@cisco.com; l=3450; q=dns/txt; s=iport; t=1330724482; x=1331934082; h=mime-version:content-transfer-encoding:subject:date: message-id:in-reply-to:references:from:to:cc; bh=VE4D6WEfI3VrOvc+IKDJAvp146iC0/N9G1nFpCQ+6f8=; b=XRAhT6RPSsxrIlFagoyAOJlWKOOKcBTpy951fFCicgcMIUKiXsrwEO95 zeaVG5E/s/XsRhJgSV4FmnRFKA9p4jOrgnL6+rnjzwf/1wKlwEHuAUOGG ENdZrcriXzmoeHVIh4zBK9ryr/ijivJbiQIkHNoQsqQ9liday8lqkUGGZ o=;
X-IronPort-Anti-Spam-Filtered true
X-IronPort-Anti-Spam-Result AgIFAEw9UU+rRDoI/2dsb2JhbABDhT+uD3iBB4F9AQEBAwESARAECQRFBQcEAgEGAg4DBAEBAwIGBhcBAgICAQFECQgBAQQTCBqHXwQMoQ8BjGWKPYEvjR8zYwSIUKAEgTMFAg
X-IronPort-AV E=Sophos;i="4.73,520,1325462400"; d="scan'208";a="34177752"
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:43:11 -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 Acz4sj3DSw719Y2tSoyEJQggsDzPVwACqlAw
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:41:19.0509 (UTC) FILETIME=[3431D450:01CCF8BD]
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.355.1330724483.3037.python-list@python.org> (permalink)
Lines 45
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1330724483 news.xs4all.nl 6917 [2001:888:2000:d::a6]:54937
X-Complaints-To abuse@xs4all.nl
Path csiph.com!usenet.pasdenom.info!news.chainon-marquant.org!feed.ac-versailles.fr!news.ecp.fr!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Xref csiph.com comp.lang.python:21150

Show key headers only | View raw


Hey All,

So maybe this part is important (after doing some troubleshooting)  hopefully not everyone has beers in hand already since its Friday :-) 

The way the code works if you want to send through the firewall (i.e.   SERVER->FIREWALL->SERVER)  I split the process into two threads.  One is listening on the egress, then I send on the ingress.  The main waits until the thread finishes (it times out after 2 seconds).  I had to do this b/c scapy (the library I used) won't let me send pcaps while I receive them.  This lets me see packets on both sides (i.e. did that sort of internet traffic go through the firewall).   The reason I think this could be a problem is when I ran a test where I sent to the firewall (rather than through it) and my program does not need to thread the webserver works fine......   

Suggestions anyone?

-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:43 -0800

csiph-web