script linux, inotify. (GitHub).
, , - , , , .. , epoll .
import inotify.adapters
i = inotify.adapters.Inotify()
i.add_watch(b'/tmp')
try:
for event in i.event_gen():
if event is not None:
(header, type_names, watch_path, filename) = event
if 'IN_MODIFY' in type_names:
# Do something
sync(sourcedir, targetdir, "sync")
finally:
i.remove_watch(b'/tmp')
, multiprocessing sync, script . sync , .
, , , .