[Twisted-Python] Two thumbs up for inotify.py
I just tried the latest inotify.py from dialtone's sandbox, and I like it. My application is a little PyGTK / Cairo recording data scope (closed source) that needs to read lots of little files and plot lots of data points in realtime. I have my own inotify/ctypes wrapper (at the time I wrote it I found two Python inotify wrappers; one was GPL and the other didn't work for me) which works okay in this application. But it's a bit gross because my call to see if there are any inotify events is blocking (with a very short timeout), rather than truly event-based. To try inotify.py, I Twistified my code (easy because it was already event-driven PyGTK), then changed all the inotify calls to use the sandbox module's API rather than mine. The only thing I disliked about the API was having to pass the callbacks are to the watch method, rather than the watch method returning a Deferred that I could addCallback on, but that's just different, not actually hard or confusing. Anyway, it works and my code is a bit smaller and cleaner than it was before and uses a tad less CPU. I hope this ends up in a Twisted release. I see #972 in the tracker, but it's been untouched for a long time. Should I comment there? Thanks. -- David Ripton dripton@ripton.net
On Dec 19, 2008, at 11:38 AM, David Ripton wrote:
To try inotify.py, I Twistified my code (easy because it was already event-driven PyGTK), then changed all the inotify calls to use the sandbox module's API rather than mine. The only thing I disliked about the API was having to pass the callbacks are to the watch method, rather than the watch method returning a Deferred that I could addCallback on, but that's just different, not actually hard or confusing.
That pisses me off too... The problem with the API you suggest is that it's a one shot API and you should keep adding those callbacks and call watch which is not doable here... I'm open to suggestions to change it even with a custom Protocol class (Which probably would fit better in Twisted maybe but that's more cumbersome than adding the callbacks IMHO).
Anyway, it works and my code is a bit smaller and cleaner than it was before and uses a tad less CPU. I hope this ends up in a Twisted release. I see #972 in the tracker, but it's been untouched for a long time. Should I comment there?
You probably should (and also add me in the CC list), then I'll take care of the reviews that will come in, I should also find the time to setup a twisted branch with ampoule inside. -- Valentino Volonghi aka Dialtone Now running MacOS X 10.5 Home Page: http://www.twisted.it http://www.adroll.com
participants (2)
-
David Ripton
-
Valentino Volonghi