MCPcopy
hub / github.com/cherrypy/cherrypy / run

Method run

cherrypy/process/plugins.py:666–696  ·  view source on GitHub ↗

Reload the process if registered files have been modified.

(self)

Source from the content-addressed store, hash-verified

664 )
665
666 def run(self):
667 """Reload the process if registered files have been modified."""
668 for filename in self.sysfiles() | self.files:
669 if filename:
670 if filename.endswith('.pyc'):
671 filename = filename[:-1]
672
673 oldtime = self.mtimes.get(filename, 0)
674 if oldtime is None:
675 # Module with no .py file. Skip it.
676 continue
677
678 try:
679 mtime = os.stat(filename).st_mtime
680 except OSError:
681 # Either a module with no .py file, or it's been deleted.
682 mtime = None
683
684 if filename not in self.mtimes:
685 # If a module has no .py file, this will be None.
686 self.mtimes[filename] = mtime
687 else:
688 if mtime is None or mtime > oldtime:
689 # The file has been deleted or modified.
690 self.bus.log('Restarting because %s changed.' %
691 filename)
692 self.thread.cancel()
693 self.bus.log('Stopped thread %r.' %
694 self.thread.name)
695 self.bus.restart()
696 return
697
698
699class ThreadManager(SimplePlugin):

Callers 3

startMethod · 0.45
startMethod · 0.45
startMethod · 0.45

Calls 6

sysfilesMethod · 0.95
statMethod · 0.80
logMethod · 0.80
cancelMethod · 0.80
getMethod · 0.45
restartMethod · 0.45

Tested by

no test coverage detected