Thanks Christoph, I've taken your suggestions and applied them to my
ThreadedAppServer for Webware 1.0.2, below:
--- WebKit/ThreadedAppServer.py.orig Mon Jun 29 08:54:13 2009
+++ WebKit/ThreadedAppServer.py Mon Jun 29 09:39:28 2009
@@ -271,6 +271,20 @@
+ import fcntl
+ except ImportError, e:
+ # Platform does not have fcntl module
+ fd = sock.fileno()
+ flags = fcntl.fcntl(fd, fcntl.F_GETFD)
+ flags |= fnctl.FD_CLOEXEC
+ except AttributeError, e:
+ # Python 2.2 does not include
+ flags |= 1
+ fcntl.fcntl(fd, fcntl.F_SETFD, flags)
print "Error: Can not listen for %s on %s" % (
Having this in the main distribution would be great!
I have a few more suggestions for upstreaming patches, which I'll send
to the list separately.
> -----Original Message-----
> From: Christoph Zwerschke [mailto:cito@...]
> Sent: Saturday, June 27, 2009 1:51 AM
> To: Discussion of Webware for Python including feedback and proposals.
> Subject: Re: [Webware-discuss] socket close-on-exec patch needed
> Hi Justin,
> > I'm in the process of upgrading Webware to version 1.0.2 from
> You probably mean 0.8.1? Please note that you should create a new app
> work dir in this case (with MakeAppWorkDir) and move your contexts
> to the new app work dir, since some things have changed here.
> > We currently have a patch that we apply to the older version to add
> > in socket close-on-exec within the ThreadedAppServer, like so:
> > Do we need to reapply this patch to Webware 1.0.2, or was
> > ThreadedAppServer rewritten to avoid this problem?
> No, it seems this patch has never been suggested. It makes sense when
> your app forks its own processes, right? I can try to get this into
> 1.0.3/1.1 (needs to be done carefully, because it works only on Unix,
> and F_SETFD and FD_CLOEXEC may not be defined in all Py versions).
> If you want to do it with Webware 1.0.2, you need to apply your patch
> after line 273 of ThreadedAppServer.py.
> -- Christoph
> Webware-discuss mailing list