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