Do the file watching in a thread to ensure that # FSEventStreamScheduleWithRunLoop and CFRunLoopRunInMode are called in the # same thread. ! # Each thread needs its own AutoreleasePool. pool = AppKit.NSAutoreleasePool.alloc().init() event_stream = FSEvents.FSEventStreamCreate( None, self._fsevents_callback, None, [self._directory], FSEvents.kFSEventStreamEventIdSinceNow, 1, # Seconds to wait to between received events. # We're interested in per-file (not per-directory) events. FSEvents.kFSEventStreamCreateFlagFileEvents, ) ! FSEvents.FSEventStreamScheduleWithRunLoop(event_stream, FSEvents.CFRunLoopGetCurrent(), FSEvents.kCFRunLoopDefaultMode)