Pylons / pyramid_debugtoolbar

Pyramid debug toolbar
https://docs.pylonsproject.org/projects/pyramid-debugtoolbar/en/latest/
Other
95 stars 82 forks source link

configurable polling of server-side events #187

Open jvanasco opened 9 years ago

jvanasco commented 9 years ago

The constant polling of the debugtoolbar has made debugging certain things difficult.

I tried turning off logging, but that was too strict a measure.

I'd like to suggest a configurable polling option.

Looking at the code, toolbar.dbtmako just uses a javascript EventSource to handle the ajax data

source = new EventSource('/_debug_toolbar/sse?request_id=${request_id}');

looking at views.py , it's seems that we're not really using a server-side push, but falling back on the HTML spec that will have browsers repoll/reconnect/retry in 3second intervals

The current template for the payload is:

U_SSE_PAYLOAD = text_("id:{0}\nevent: new_request\ndata:{1}\n\n")

And we can minimally edit that to have full control of the retry (in ms)

U_SSE_PAYLOAD = text_("id:{0}\nevent: new_request\ndata:{1}\n\nretry: {2}\n\n")

The default behavior is equivalent to 3000 ; a simple config file edit could let this be 60,000 or 1,000 or whatever is easiest for a developer.

mmerickel commented 9 years ago

If you want to provide a patch to modify the polling interval that would be fine.

Presumably a debugtoolbar.refresh_interval ini setting that defaulted to the current 1000ms.