(self)
| 402 | SLEEP_TIME = 1 # Check for changes once per second. |
| 403 | |
| 404 | def tick(self): |
| 405 | mtimes = {} |
| 406 | while True: |
| 407 | for filepath, mtime in self.snapshot_files(): |
| 408 | old_time = mtimes.get(filepath) |
| 409 | mtimes[filepath] = mtime |
| 410 | if old_time is None: |
| 411 | logger.debug("File %s first seen with mtime %s", filepath, mtime) |
| 412 | continue |
| 413 | elif mtime > old_time: |
| 414 | logger.debug( |
| 415 | "File %s previous mtime: %s, current mtime: %s", |
| 416 | filepath, |
| 417 | old_time, |
| 418 | mtime, |
| 419 | ) |
| 420 | self.notify_file_changed(filepath) |
| 421 | |
| 422 | time.sleep(self.SLEEP_TIME) |
| 423 | yield |
| 424 | |
| 425 | def snapshot_files(self): |
| 426 | # watched_files may produce duplicate paths if globs overlap. |
nothing calls this directly
no test coverage detected