I have a pyinotify watcher running threaded, called as a separate class, at the moment it just prints its discoveries in a terminal window, if I wanted my script to make an action based on those changes am I better to:
A) modify an array with each notification
B) write to a file in /tmp and fetch it from my main script?
c) give up programm开发者_JS百科ing
thanks for any input,
Stewart
import Queue
changes = Queue.Queue()
and now use changes.put
in the thread that discover the changes, changes.get
in the thread that is supposed to act on those changes (there are several other useful methods in Queue
that you should check -- also note, per the docs, that the module's renamed to queue
, all lowercase, in Python 3). Queues are intrinsically thread-safe and therefore often the best way to arrange cooperation among threads in Python.
精彩评论