mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 10:16:27 +00:00
script reloader: minor fixes
This commit is contained in:
parent
63355421ed
commit
3eea7f1216
@ -6,6 +6,8 @@ _observers = {}
|
||||
|
||||
|
||||
def watch(script, callback):
|
||||
if script in _observers:
|
||||
raise RuntimeError("Script already observed")
|
||||
script_dir = os.path.dirname(os.path.abspath(script.args[0]))
|
||||
event_handler = _ScriptModificationHandler(callback)
|
||||
observer = Observer()
|
||||
@ -18,6 +20,7 @@ def unwatch(script):
|
||||
observer = _observers.pop(script, None)
|
||||
if observer:
|
||||
observer.stop()
|
||||
observer.join()
|
||||
|
||||
|
||||
class _ScriptModificationHandler(PatternMatchingEventHandler):
|
||||
|
Loading…
Reference in New Issue
Block a user