-
-
Notifications
You must be signed in to change notification settings - Fork 766
Add support for PyCharm Pro's Remote Debug Server #5674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -19,6 +19,7 @@ | |||||||||||||
|
||||||||||||||
from __future__ import absolute_import | ||||||||||||||
|
||||||||||||||
import os | ||||||||||||||
import sys | ||||||||||||||
|
||||||||||||||
__all__ = [ | ||||||||||||||
|
@@ -43,6 +44,23 @@ def monkey_patch(patch_thread=None): | |||||||||||||
patched unless debugger is used. | ||||||||||||||
:type patch_thread: ``bool`` | ||||||||||||||
""" | ||||||||||||||
if os.environ.get("ST2_PYCHARM_DEBUG", False): | ||||||||||||||
|
||||||||||||||
# pydevd_pycharm uses this to save copies of stdlib modules before | ||||||||||||||
# eventlet monkey patches them, or the debugger will not work. | ||||||||||||||
# see: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000333980 | ||||||||||||||
os.environ["GEVENT_SUPPORT"] = "True" | ||||||||||||||
|
||||||||||||||
import pydevd_pycharm | ||||||||||||||
|
||||||||||||||
pydevd_pycharm.settrace( | ||||||||||||||
os.environ.get("ST2_PYCHARM_DEBUG_HOST", "localhost"), | ||||||||||||||
port=os.environ.get("ST2_PYCHARM_DEBUG_PORT", 5000), | ||||||||||||||
stdoutToServer=True, | ||||||||||||||
stderrToServer=True, | ||||||||||||||
patch_multiprocessing=True, | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
# Eventlet when patched doesn't throw the standard ssl error on timeout, which can break | ||||||||||||||
# some third-party libraries including redis SSL. | ||||||||||||||
# See: https://github.com/eventlet/eventlet/issues/692 | ||||||||||||||
|
@@ -117,4 +135,8 @@ def is_use_debugger_flag_provided(): | |||||||||||||
if arg.startswith(PARENT_ARGS_FLAG) and USE_DEBUGGER_FLAG in arg: | ||||||||||||||
return True | ||||||||||||||
|
||||||||||||||
# 3. Check for ST2_PYCHARM_DEBUG env var | ||||||||||||||
if os.environ.get("ST2_PYCHARM_DEBUG", False): | ||||||||||||||
return True | ||||||||||||||
Comment on lines
+138
to
+140
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This part is not pycharm specific - it allows enabling debug mode via env var instead of changing the cli args.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK I split this change into a separate PR: #5675 |
||||||||||||||
|
||||||||||||||
return False |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@armab Do you have a recommendation on how we can make this extensible so that people can inject whatever debugger before monkey_patching occurs?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about something like:
Then, I would only need to install a package in the st2 virtualenv that provides a pycharm-specific version of the
st2_3rd_party_debugger
module.@armab what do you think of this solution for enabling me to inject the debugger without adding anything IDE-specific, and without patching the st2 code.