Reputation: 1517
I have the application, which runs when new file appears in specific directory. For this purpose I use nncron (cron for windows), an example
#(
500 VALUE MonitorDirTimeout
WatchDir: "c:\directory" WatchSubtree
WATCH-CHANGE-LAST-WRITE
Action:
StartIn: "c:\directory"
SWHide NormalPriority
START-APP: c:\app.py
)#
I want to use event-driven programming and Twisted, and want to execute callback when new file appears in directory. Of course, I can monitor directory by using LoopingCall, but its not event-driven.
Upvotes: 1
Views: 403
Reputation: 1832
I don't do enough windows to have a direct solution but you might be able to find your way by searching for your desired events in the system calls that makeup your given reactor/eventloop. (I.E. search OS level API docs, don't limit your search to python or twisted)
From twisted reactor docs I see WFMO and IOCP are the system frameworks used in the Windows reactors. If you can find windows docs that explain how to trigger either of those event systems on a directory update then there should be a direct way to trigger (and not have to poll) in twisted, though you might have to write some interface code if your the first in this space.
BTW there are an array of (non-twisted) ideas in this SO: How do I watch a file for changes using Python?, with the most directly relevant being: Watch a Directory for Changes
Upvotes: 2