[Twisted-Python] Problem w/ TNPE Example on Windows

Hello, I'm new to Twisted and just started reading "Twisted Network Programming Essentials". The example "dataforward.py" in chapter 2 creates a traceback and an import error, if executed on my laptop running WinXP/Pro-SP2, using Python-2.4.2 and Twisted-2.1.0 The import error complains about a missing module "fcntl" required by ...\twisted\internet\fdesc.py Reading the python documentation states that the "fcntl" module is available on Unix only. - Does that mean, that this example is working on Unix only or what am I missing? Kind regards, Viktor Ransmayr

On Sun, Dec 18, 2005 at 10:29:50PM +0100, Viktor Ransmayr wrote:
That's right, unfortunately. That example uses the twisted.internet.stdio module, which relies on fcntl (and the ability to pass the stdin/stdout file descriptors to select), which isn't available on Windows. -Andrew.

Andrew Bennetts wrote:
And unfortunately I failed to notice this while writing the book. Apologies to Windows users. Is it really impossible to do asynchronous IO on stdin/out on Windows? Anybody have any ideas for working around the lack of fcntl? I'd be happy to contribute to an effort to make twisted.internet.stdio run on Windows. Abe

Itamar Shtull-Trauring a écrit :
Talking about that, what is the exact status of the IOCP reactor? I have seen J. Johnson commiting patches related to process creation recently. Are there still mandatory features missing to have complete reactor? Patrick Mézard

Itamar Shtull-Trauring wrote:
No, it's my fault. Don't worry about it. The buck stops here. You can make it up to me by helping make twisted.internet.stdio work on Windows though :-)
It may be possible to do stdio on Windows using the IOCP reactor.
According to the inline docs, twisted.internet.stdio is: unstable (pending deprecation in favor of a reactor-based API) Future Plans: support for stderr, perhaps Rewrite to use the reactor instead of an ad-hoc mechanism for connecting protocols to transport. So for now, stdio in Twisted isn't reactor specific. As we're discussing here, though, it only works on Unixy operating systems. Would it be sane to try and import the fcntl module, and if that fails fall back to using threads to fake async stdio? Abe

On Sun, Dec 18, 2005 at 10:29:50PM +0100, Viktor Ransmayr wrote:
That's right, unfortunately. That example uses the twisted.internet.stdio module, which relies on fcntl (and the ability to pass the stdin/stdout file descriptors to select), which isn't available on Windows. -Andrew.

Andrew Bennetts wrote:
And unfortunately I failed to notice this while writing the book. Apologies to Windows users. Is it really impossible to do asynchronous IO on stdin/out on Windows? Anybody have any ideas for working around the lack of fcntl? I'd be happy to contribute to an effort to make twisted.internet.stdio run on Windows. Abe

Itamar Shtull-Trauring a écrit :
Talking about that, what is the exact status of the IOCP reactor? I have seen J. Johnson commiting patches related to process creation recently. Are there still mandatory features missing to have complete reactor? Patrick Mézard

Itamar Shtull-Trauring wrote:
No, it's my fault. Don't worry about it. The buck stops here. You can make it up to me by helping make twisted.internet.stdio work on Windows though :-)
It may be possible to do stdio on Windows using the IOCP reactor.
According to the inline docs, twisted.internet.stdio is: unstable (pending deprecation in favor of a reactor-based API) Future Plans: support for stderr, perhaps Rewrite to use the reactor instead of an ad-hoc mechanism for connecting protocols to transport. So for now, stdio in Twisted isn't reactor specific. As we're discussing here, though, it only works on Unixy operating systems. Would it be sane to try and import the fcntl module, and if that fails fall back to using threads to fake async stdio? Abe
participants (6)
-
Abe Fettig
-
Andrew Bennetts
-
Itamar Shtull-Trauring
-
James Y Knight
-
Patrick Mézard
-
Viktor Ransmayr