[Twisted-Python] Watching a File Descriptor

Thomas Hervé therve at free.fr
Sun Jan 21 13:20:43 EST 2007


Quoting Justin Mazzola Paluska <jmp at MIT.EDU>:

> Hi,
>
> I’m playing with the inotify(7) interface on Linux.  When I call
> inotify_init(), I get back a file descriptor that I’m supposed read
> from when there are file system events.
>
> What’s the best way to integrate the inotify file descriptor into the
> Twisted reactor?  My question has two subparts:
>
> 1.  How do I tell Twisted to check my fd for readability? (Is
>    reactor.addReader() all I need?
>
> 2.  How do I register a callback to my own code when my fd is
>    readable?
>
> All in all, it seems what I really want is something like
> ProcessProtocol, but without spawning a process.  Forgive me if I’ve
> missed something obvious, but searching google and the gmane mail
> archives hasn’t turned up anything.

You should have a look at this:

http://twistedmatrix.com/trac/browser/sandbox/inotify.py

-- 
Thomas





More information about the Twisted-Python mailing list