[Twisted-Python] Opening a fifo

Phil Mayers p.mayers at imperial.ac.uk
Fri Nov 14 06:00:33 EST 2008


Paul Thomas wrote:
> 
> On 14 Nov 2008, at 09:47, Phil Mayers wrote:
> 
>> Paul Thomas wrote:
>>> Hi,
>>> 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')
1

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?




More information about the Twisted-Python mailing list