Damian Cugley’s Weblog
I have converted the Picky Picky Game so that it can run as a
BaseHTTPServer
server as an alternative to as a
CGI script, in
order to avoid the performance penalty caused by starting up
fresh Python processes for each request. But I discovered
that the sevrer would lock up from time to time.
It was no ordinary lock-up: it could not be interrupted with
Ctrl-C (but Ctrl-\ worked). After an
abortive attempt to use GDB to debug Python itself, I added the
usual plethora of print
statements to narrow down
the place where it went wrong, and it seemed to be in connecting
to the ZODB database. In the end I changed my code to keep
track of the connection object it gets from the database and to
explicitly call con.close()
(rather than assuming
this would happen automatically when the variable goes out of
scope). The problem now appears to have gone away.
Thus it is I can run the Picky Picky Game as a
free-standing web server (running as
http://caption.org:8005/a/
, for example) as an
alternative to running it via CGI. At least, I can so long
as I remain connected to the sevrer with SSH; I need
to persuade Adrian to run the free-standing server as a daemon.
In the meantime,
you can visit the CGI version at http://caption.org/caption-cgi/hello.cgi/sample/
.
My link for Approval Voting has rotted and needs to be updated. Sigh. Another description of Approval Vote
The next thing to do is to separate out the base URL for static files (such as the style sheet) so that these files need no longer be tangled up with the resources served by the CGI script (or by the free-standing server).