[Twisted-Python] odd problem with daemonization?
glyph at twistedmatrix.com
Wed Mar 19 01:02:46 EST 2003
-----BEGIN PGP SIGNED MESSAGE-----
On Tuesday, March 18, 2003, at 05:08 PM, Bruce Mitchener wrote:
> I've got a pretty simple server using a factory and some protocol
> objects. This code handles access to an extension module (the details
> of which are probably not useful, but it is written in C++, wrapped
> with SWIG) which implements the majority of our application logic.
Just a brief word of warning... while I've had a few good experiences
integrating C/C++ code with Python, SWIG has uniformly been horrible.
This particular issue is not with SWIG, but it may create interference
> The C++ code tends to dump a ton of output to stdout, and when I
> twistd like this:
> twistd -f myveryown.tap
> and have a connected protocol instance, the log out put from the C++
> code end up getting written directly to the socket and sent to the
The reason that you're having this problem is that on the C++ side of
things, FD 0,1,2 are just normal FDs. This is due to the fact that we
trap the sys.stdout _object_ in python, but we don't keep the
file-descriptors around. The Transport of your Protocol is getting
created after those FDs have been closed, and is therefore haplessly
allocating the FD of stdout by chance.
I don't know how to create a file-descriptor in C which translates to
function calls on a Python file-type object. In fact, I don't even
know if that's possible. However, this is clearly incorrect behavior
for cout<< and printf. Can anyone with more experience in this area
propose a solution?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (Darwin)
-----END PGP SIGNATURE-----
More information about the Twisted-Python