MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / FSNotifyThread

Class FSNotifyThread

_pydevd_bundle/pydevd_comm.py:330–360  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

328
329
330class FSNotifyThread(PyDBDaemonThread):
331 def __init__(self, py_db, api, watch_dirs):
332 PyDBDaemonThread.__init__(self, py_db)
333 self.api = api
334 self.name = "pydevd.FSNotifyThread"
335 self.watcher = fsnotify.Watcher()
336 self.watch_dirs = watch_dirs
337
338 @overrides(PyDBDaemonThread._on_run)
339 def _on_run(self):
340 try:
341 pydev_log.info("Watching directories for code reload:\n---\n%s\n---" % ("\n".join(sorted(self.watch_dirs))))
342
343 # i.e.: The first call to set_tracked_paths will do a full scan, so, do it in the thread
344 # too (after everything is configured).
345 self.watcher.set_tracked_paths(self.watch_dirs)
346 while not self._kill_received:
347 for change_enum, change_path in self.watcher.iter_changes():
348 # We're only interested in modified events
349 if change_enum == fsnotify.Change.modified:
350 pydev_log.info("Modified: %s", change_path)
351 self.api.request_reload_code(self.py_db, -1, None, change_path)
352 else:
353 pydev_log.info("Ignored (add or remove) change in: %s", change_path)
354 except:
355 pydev_log.exception("Error when waiting for filesystem changes in FSNotifyThread.")
356
357 @overrides(PyDBDaemonThread.do_kill_pydev_thread)
358 def do_kill_pydev_thread(self):
359 self.watcher.dispose()
360 PyDBDaemonThread.do_kill_pydev_thread(self)
361
362
363class WriterThread(PyDBDaemonThread):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected