Closed dvirtz closed 3 years ago
This is a weird issue and I guess it has something to do with the mechanism of os.environ
. I'm not able to crack it to the bottom, but I changed the way watchpoints monitors variables. In short, when you assign a string a
with a different id
to a variable that has a
already, it won't trigger the monitor now. The fix should be released soon.
As for the deadlock, I can reproduce it in VSCode terminal, but not with pure WSL Ubuntu. Are you doing this in VSCode as well? I suspected it has something to do with VSCode. And it's also fixed with the patch(for me).
Thanks. I did use VSCode terminal. I'll check the fix when it will be released.
The fix is released with 0.2.3
I can verify the original code works with 0.2.3, however, if I try to add a watch inside a function like in
import os
from watchpoints import watch
def run():
os.environ['a'] = 'before'
watch(os.environ['a'])
os.environ['a'] = 'after'
if __name__ == '__main__':
run()
I get
Traceback (most recent call last):
File "./watch_environ.py", line 10, in <module>
run()
File "./watch_environ.py", line 6, in run
watch(os.environ['a'])
File "/home/conan/.local/lib/python3.6/site-packages/watchpoints/watch.py", line 44, in __call__
stack_limit=kwargs.get("stack_limit", self.stack_limit)
File "/home/conan/.local/lib/python3.6/site-packages/watchpoints/watch_element.py", line 14, in __init__
exec(code, {}, f_locals)
File "<string>", line 1, in <module>
NameError: name 'os' is not defined
Good catch, this is a valid bug.
Should be fixed in 0.2.4, thanks for noticing it.
running the code
results in the following
verbose output
``` ====== Watchpoints Triggered ====== Call Stack (most recent call last):the execution than hangs as if in a deadlock, and killing it prints