Created
August 13, 2019 16:18
-
-
Save kylrth/148f061c1f4126dca2bd73cb9ad33007 to your computer and use it in GitHub Desktop.
Debugging Bokeh server applications using Visual Studio Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ptvsd | |
# attach to VS Code debugger if this script was run with BOKEH_VS_DEBUG=true | |
if os.environ['BOKEH_VS_DEBUG'] == 'true': | |
# 5678 is the default attach port in the VS Code debug configurations | |
print('Waiting for debugger attach') | |
ptvsd.enable_attach(address=('localhost', 5678), redirect_output=True) | |
ptvsd.wait_for_attach() | |
def main(): | |
"""Create the root and add it to `curdoc()`.""" | |
raise NotImplementedError() | |
if __name__.startswith('bk_script'): | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"name": "Bokeh server", | |
"type": "python", | |
"request": "attach", | |
"port": 5678, | |
"host": "localhost", | |
"preLaunchTask": "launch Bokeh server" | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "2.0.0", | |
"tasks": [ | |
{ | |
"label": "launch Bokeh server", | |
"type": "shell", | |
"isBackground": true, | |
"command": "bokeh", | |
"args": [ | |
"serve", | |
"app.py" | |
], | |
"options": { | |
"env": { | |
"BOKEH_VS_DEBUG": "true" | |
} | |
}, | |
"problemMatcher": { | |
"fileLocation": [ | |
"relative", | |
"${workspaceFolder}" | |
], | |
"pattern": [ | |
{ | |
"regexp": ".", | |
"file": 1, | |
"location": 2, | |
"message": 3 | |
} | |
], | |
"background": { | |
"activeOnStart": true, | |
"endsPattern": "^.*Waiting for debugger attach.*", | |
"beginsPattern": "^this should not match on anything" | |
// "^.*\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2},\\d{3} 200 GET.*" | |
} | |
} | |
} | |
] | |
} |
hi, I would need some help understanding this.
1st) it gives an error on BOKEH_VS_DEBUG ... whats this?
That line is reading an environment variable from the shell. You can see it set on line 15 of tasks.json5
. Be sure to copy that file into your VS Code debugging configuration.
I'm traying to do this with visual studio. is it the same or similar( vstudio debugging config)?
where do I save tasks.json?
It is only for VS Code, not Visual Studio.
…On Tue, Jun 28, 2022, 14:46 Ron Mc ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
where do I sabe tasks.json?
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/148f061c1f4126dca2bd73cb9ad33007#gistcomment-4215351>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABGPUQSRHEFU2SPFCYKDZ43VRNQEBANCNFSM4ILMQFHQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use this, start debugging, then navigate to the Bokeh app in your browser.