[Twisted-Python] Named Pipes
wari at home.wari.org
Sat May 17 00:45:45 EDT 2003
Moshe Zadka wrote:
>>Hi, is there a way to get twisted to listen to a named pipe like it's a
>>TCP connection or something? How would I go about it?
> It's fairly easy, and probably should be done in Twisted at some point.
Ah, I got my own based on stdio.StandardIO and that does not work the
way I want, this way seems better :)
> from twisted.internet import abstract, fdesc
> class SelectableFile(abstract.FileDescriptor):
> def __init__(self, fp, protocol):
> self.fp = fp
> self.protocol = protocol
> self.fileno = self.fp.fileno
> def doRead(self):
> buf = self.fp.read(4096)
I had to do this on a try block:
buf = self.fp.read(4096)
buf = None
> if buf:
> def write(self, data):
> pass # what can we do with the data?
> def loseConnection(self):
Wait, how did you guys make it so easy? :) Anyway, I find that
loseConnection is never called (when I restart syslog, or when I deleted
the named pipe), this thing goes on like a battery, of course the effect
of deleting the file and recreating it does not get the communications
working anymore because of inode/filepointer diffences.
Thanks for pointing this one out to me.
Regards: Wari Wahab
RoughingIT - http://roughingit.subtlehints.net
PyBlosxom - http://roughingit.subtlehints.net/pyblosxom
More information about the Twisted-Python