gaogaotiantian / watchpoints

watchpoints is an easy-to-use, intuitive variable/object monitor tool for python that behaves similar to watchpoints in gdb.
Apache License 2.0
497 stars 20 forks source link

Compatibility with Flask #36

Open MagnusOxlund opened 9 months ago

MagnusOxlund commented 9 months ago

I've been trying to use watch with Flask, but the output doesn't appear in the terminal until after the Flask application has terminated.

from watchpoints import watch
from flask import Flask

app = Flask('app')

x = None
watch(x)

@app.route('/')
def change_x():
    global x
    x = "Something"     # no output until after app.run terminates
    print("manual print")   # prints immediately
    return x

app.run('0.0.0.0', 500, debug=True, use_reloader=True)

Is there a way to output immediately?

gaogaotiantian commented 9 months ago

Ah, that's actually a bug for watchpoints. watchpoints does not deal with global variables well. Also I'll have to be honest that this library has not been actively maintained. Personally I loved this black magic library but not there are not a lot of active users to make maintenance worthy.

MagnusOxlund commented 9 months ago

I'm surprised to hear that. I can't imagine a better way to monitor variables that are involved in a complex interaction. Personally, I'm dealing with cached quasi-global proxy objects and hooks or signals being accessed by external modules I'm still getting to know. It can take quite a while to track down issues.

I only just discovered your project yesterday. Hopefully it will garner more attention and catch on.