Last active
August 29, 2015 14:10
-
-
Save jmcmellen/0e14760e3fd35fddbe90 to your computer and use it in GitHub Desktop.
Watch a folder with pyuv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import signal | |
import pyuv | |
def on_fs_event(evt_handle, filename, events, error): | |
print evt_handle.filename, events | |
def handler_closing(handle): | |
print "Closing", handle | |
handle.close(handler_closed) | |
def handler_closed(handle): | |
print handle, "Handler closed" | |
def catch_signals(sig_handle, sig_num): | |
loop.walk(handler_closing) | |
#fs_events.close(handler_closed) | |
#sig_handle.close() | |
loop = pyuv.Loop.default_loop() | |
fs_events = pyuv.fs.FSEvent(loop, '.', on_fs_event, 0) | |
signal_h = pyuv.Signal(loop) | |
signal_h.start(catch_signals, signal.SIGINT) | |
loop.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment