fcgi.py

Victor Muslin victor at prodigy.net
Thu Dec 28 01:32:19 CET 2000


Sorry for newbie questions, but I ran into a couple of problems with
fcgi.py. I am using Python 1.5.2 on WindowsNT 4.0.

1) I tried to run fcgi.py from the command line (to exercise its
_test() function) and received the following error message:

	D:/Apps/apache/cgi-bin> fcgi.py
	Exception exceptions.AttributeError: 'err' in <method
FCGI.__del__ of FCGI instance at 82a220> ignored

The traceback was:

	Traceback (innermost last):
	  File "fcgi.py", line 386, in _test
	    req = Accept()
	  File "fcgi.py", line 231, in __init__
	    _startup()
	  File "fcgi.py", line 367, in _startup
	    s=socket.fromfd(sys.stdin.fileno(), socket.AF_INET,
	AttributeError: fromfd

Seems that the socket module for WindowsNT Python 1.5.2 does not have
fromfd() method.

Here's the proof (at least for my Python installation):

>>> pprint.pprint(dir(socket))
['AF_INET',
 'INADDR_ALLHOSTS_GROUP',
 'INADDR_ANY',
 'INADDR_BROADCAST',
 'INADDR_LOOPBACK',
 'INADDR_MAX_LOCAL_GROUP',
 'INADDR_NONE',
 'INADDR_UNSPEC_GROUP',
 'IPPORT_RESERVED',
 'IPPORT_USERRESERVED',
 'IPPROTO_GGP',
 'IPPROTO_ICMP',
 'IPPROTO_IDP',
 'IPPROTO_IGMP',
 'IPPROTO_IP',
 'IPPROTO_MAX',
 'IPPROTO_ND',
 'IPPROTO_PUP',
 'IPPROTO_RAW',
 'IPPROTO_TCP',
 'IPPROTO_UDP',
 'IP_ADD_MEMBERSHIP',
 'IP_DROP_MEMBERSHIP',
 'IP_MULTICAST_IF',
 'IP_MULTICAST_LOOP',
 'IP_MULTICAST_TTL',
 'IP_OPTIONS',
 'IP_TOS',
 'IP_TTL',
 'MSG_DONTROUTE',
 'MSG_OOB',
 'MSG_PEEK',
 'SOCK_DGRAM',
 'SOCK_RAW',
 'SOCK_RDM',
 'SOCK_SEQPACKET',
 'SOCK_STREAM',
 'SOL_SOCKET',
 'SOMAXCONN',
 'SO_ACCEPTCONN',
 'SO_BROADCAST',
 'SO_DEBUG',
 'SO_DONTROUTE',
 'SO_ERROR',
 'SO_KEEPALIVE',
 'SO_LINGER',
 'SO_OOBINLINE',
 'SO_RCVBUF',
 'SO_RCVLOWAT',
 'SO_RCVTIMEO',
 'SO_REUSEADDR',
 'SO_SNDBUF',
 'SO_SNDLOWAT',
 'SO_SNDTIMEO',
 'SO_TYPE',
 'SO_USELOOPBACK',
 'SocketType',
 '__builtins__',
 '__doc__',
 '__file__',
 '__name__',
 '_fileobject',
 '_realsocketcall',
 '_socketobject',
 'error',
 'errorTab',
 'gethostbyaddr',
 'gethostbyname',
 'gethostbyname_ex',
 'gethostname',
 'getprotobyname',
 'getservbyname',
 'htonl',
 'htons',
 'ntohl',
 'ntohs',
 'socket']
>>>

socket.fromfd() method is called in the fcgi._startup() function,
which is called in the constructor of FCGI object. Since
fcgi._startup() function is catching only socket.error exceptions
instead of AttributeError exception the program dumps.

If AttributeError except clause is added immediately after the
socket.error() in fcgi._startup():

    except AttributeError:
            global _isFCGI
            _isFCGI = 0
            return

then the program works fine.

Is there something I am doing wrong or is there something wrong with
my Python installation?

2) I was wondering whether it is possible to use fcgi.py based
programs with Apache using cgi-fcgi brdige. If so, how would one
configure cgi-fcgi to know to launch a python interpreter with a
specific program to interpret? If there is an example it would be
greatly appreciated.

Thanks



More information about the Python-list mailing list