Python - CGI-BIN - Apache Timeout Problem

Sean Cavanaugh (scavanau) scavanau at
Sun Mar 4 19:07:57 CET 2012

Thanks Chris,

I isolated it using logging

import logging 
logging.basicConfig(filename="test3.log", level=logging.INFO)
then'sniffer got to point A')  

and going through my code until I isolated the problem to a function with scapy called sniff.  For some reason this function operates very weirdly on FreeBSD9.  I have already submitted an email to the scapy mailing list.  Going to try to replicate this on Fedora but I doubt I will see this problem.  Even from the command line the sniff() function is not working correctly on FreeBSD 9.


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

On Fri, Mar 2, 2012 at 12:09 PM, Sean Cavanaugh (scavanau)
<scavanau at> wrote:
> When I execute the scripts from the command line (#python 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', ''],
> stdout=subprocess.PIPE)
>         output =

Note the red warning box about possible deadlock with
and friends:

>         print output
>         proc.stdout.close()

As the docs advise, try using .communicate()
] instead:
    proc = subprocess.Popen(…)
    out, err = proc.communicate()
    print out

> When I open 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.


More information about the Python-list mailing list