[Twisted-Python] Looking for a simple file event driven loop using Twisted
Ken Kinder
ken at kenkinder.com
Fri Mar 25 19:39:53 EST 2005
It seems to me you probably will either check periodically in the
reactor, like this:
def checkFile():
x = os.stat(file)
...
reactor.callLater(.5, checkFile)
reactor.callWhenRunning(checkFile)
Or just start another thread like this:
def wakeUp():
(action to take when file changes)
def checker():
while 1:
(code that waits for file to change)
reactor.callFromThread(wakeUp)
reactor.callInThread(checker)
-Ken
steven howe wrote:
>Hello,
>I'm looking for some example code I can use to build an app from. I
>need to 'wait' or sleep for new data in a file. Then wake and process
>the data.
>
>The file is a regular file, not a pipe. It is the output of a existing
>program (i.e., not mine to modify). Needless to say, the API for hugh.
>I'm need some help finding the right tools.
>
>Thanks,
>
>Steven Howe
>
>_______________________________________________
>Twisted-Python mailing list
>Twisted-Python at twistedmatrix.com
>http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
>
More information about the Twisted-Python
mailing list