MCPcopy
hub / github.com/mitmproxy/mitmproxy / watcher

Method watcher

mitmproxy/addons/script.py:133–150  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

131 ctx.master.addons.invoke_addon_sync(self.ns, hooks.RunningHook())
132
133 async def watcher(self):
134 # Script loading is terminally confused at the moment.
135 # This here is a stopgap workaround to defer loading.
136 await asyncio.sleep(0)
137 last_mtime = 0.0
138 while True:
139 try:
140 mtime = os.stat(self.fullpath).st_mtime
141 except FileNotFoundError:
142 logger.info("Removing script %s" % self.path)
143 scripts = list(ctx.options.scripts)
144 scripts.remove(self.path)
145 ctx.options.update(scripts=scripts)
146 return
147 if mtime > last_mtime:
148 self.loadscript()
149 last_mtime = mtime
150 await asyncio.sleep(ReloadInterval)
151
152
153class ScriptLoader:

Callers 1

__init__Method · 0.95

Calls 4

loadscriptMethod · 0.95
infoMethod · 0.80
removeMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected