[Twisted-Python] Opening a fifo
pthomas at spongelava.com
Fri Nov 14 06:39:19 EST 2008
On 14 Nov 2008, at 11:00, Phil Mayers wrote:
> Paul Thomas wrote:
>> On 14 Nov 2008, at 09:47, Phil Mayers wrote:
>>> Paul Thomas wrote:
>>>> I've run into a small problem where my twisted application needs
>>>> to open a fifo to talk to another process. On Linux at least, the
>>>> open blocks until the other end of the fifo is opened and this is
>>>> blocking my reactor.
>>> Either of:
>>> fd = os.open('thefifo', os.O_RDONLY | os.O_NONBLOCK)
>>> fd = os.open('thefifo', os.O_RDWR)
>>> ...will return immediately,
>>> Try "man fifo" for a description of the vagaries.
>> I've tried RDWR and I get errors in writing. I really need
>> O_WRONLY, and that fails with O_NONBLOCK unless the other end is
>> open. Maybe I'll chase down the RDWR problem again.
> Really? It works for me in a repl:
> [pjm3 at wildfire ~]$ mkfifo blah
> [pjm3 at wildfire ~]$ python
> >>> import os
> >>> fd = os.open('blah', os.O_RDWR)
> >>> os.write(fd, 'a')
> What errors are you getting? Possibly Twisted is getting confused
> because the fd is "readable" as well as "writeable".
> Do you have sample code that's failing?
I'll have to wait til Monday to try it out again. I thought the
problem was to do with the other process opening the read end between
the open and the write. But maybe it was a case of not testing what I
thought I was testing.
Still, so long as I know that twisted doesn't provide anything I might
have missed, and that you think it should work, I can focus on fixing
it instead of working around it.
More information about the Twisted-Python