Thanks Christoph, I've taken your suggestions and applied them to my
patchset for
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 @@
try:
sock.bind(serverAddress)
sock.listen(1024)
+ try:
+ import fcntl
+ except ImportError, e:
+ # Platform does not have fcntl module
+ pass
+ else:
+ fd = sock.fileno()
+ flags = fcntl.fcntl(fd, fcntl.F_GETFD)
+ try:
+ flags |= fnctl.FD_CLOEXEC
+ except AttributeError, e:
+ # Python 2.2 does not include
FD_CLOEXEC
+ flags |= 1
+ fcntl.fcntl(fd, fcntl.F_SETFD, flags)
except Exception:
print "Error: Can not listen for %s on %s" % (
handlerClass.settingPrefix,
str(serverAddress))
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.
-Justin Akehurst
> -----Original Message-----
> From: Christoph Zwerschke [mailto:[email protected]]
> 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
anymore on
> ThreadedAppServer?
>
> Hi Justin,
>
> > I'm in the process of upgrading Webware to version 1.0.2 from
version
> 0.8.4
>
> 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
etc.
> 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
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/webware-discuss
------------------------------------------------------------------------------
_______________________________________________
Webware-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/webware-discuss