Skip to content

Commit

Permalink
wip format 3
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioz committed Feb 18, 2024
1 parent 8359e25 commit b980e5a
Show file tree
Hide file tree
Showing 8 changed files with 9,342 additions and 8,773 deletions.
56 changes: 39 additions & 17 deletions _pydevd_bundle/pydevd_additional_thread_info_regular.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@
# =======================================================================================================================
# PyDBAdditionalThreadInfo
# =======================================================================================================================
# fmt: off
# IFDEF CYTHON
# cdef class PyDBAdditionalThreadInfo:
# ELSE
class PyDBAdditionalThreadInfo(object):
# ENDIF
# ENDIF
# fmt: on

# Note: the params in cython are declared in pydevd_cython.pxd.
# fmt: off
# IFDEF CYTHON
# ELSE
__slots__ = [
Expand Down Expand Up @@ -61,6 +64,7 @@ class PyDBAdditionalThreadInfo(object):
"is_in_wait_loop",
]
# ENDIF
# fmt: on

def __init__(self):
self.pydev_state = STATE_RUN # STATE_RUN or STATE_SUSPEND
Expand Down Expand Up @@ -114,11 +118,13 @@ def __init__(self):
# to pause).
self.is_in_wait_loop = False

# fmt: off
# IFDEF CYTHON
# cpdef object _get_related_thread(self):
# cpdef object _get_related_thread(self):
# ELSE
def _get_related_thread(self):
# ENDIF
# ENDIF
# fmt: on
if self.pydev_notify_kill: # Already killed
return None

Expand All @@ -141,11 +147,13 @@ def _get_related_thread(self):

return thread

# fmt: off
# IFDEF CYTHON
# cpdef bint _is_stepping(self):
# cpdef bint _is_stepping(self):
# ELSE
def _is_stepping(self):
# ENDIF
# ENDIF
# fmt: on
if self.pydev_state == STATE_RUN and self.pydev_step_cmd != -1:
# This means actually stepping in a step operation.
return True
Expand All @@ -157,11 +165,13 @@ def _is_stepping(self):

return False

# fmt: off
# IFDEF CYTHON
# cpdef get_topmost_frame(self, thread):
# cpdef get_topmost_frame(self, thread):
# ELSE
def get_topmost_frame(self, thread):
# ENDIF
# ENDIF
# fmt: on
"""
Gets the topmost frame for the given thread. Note that it may be None
and callers should remove the reference to the frame as soon as possible
Expand All @@ -184,11 +194,13 @@ def get_topmost_frame(self, thread):

return topmost_frame

# fmt: off
# IFDEF CYTHON
# cpdef update_stepping_info(self):
# cpdef update_stepping_info(self):
# ELSE
def update_stepping_info(self):
# ENDIF
# ENDIF
# fmt: on
_update_stepping_info(self)

def __str__(self):
Expand All @@ -199,11 +211,13 @@ def __str__(self):
_next_additional_info = [PyDBAdditionalThreadInfo()]


# fmt: off
# IFDEF CYTHON
# cpdef set_additional_thread_info(thread):
# ELSE
def set_additional_thread_info(thread):
# ENDIF
# ENDIF
# fmt: on
try:
additional_info = thread.additional_info
if additional_info is None:
Expand Down Expand Up @@ -232,24 +246,28 @@ def set_additional_thread_info(thread):
return additional_info


# fmt: off
# IFDEF CYTHON
# cdef set _all_infos
# cdef set _infos_stepping
# cdef object _update_infos_lock
# ELSE
# ENDIF

# fmt: on

_all_infos = set()
_infos_stepping = set()
_update_infos_lock = ForkSafeLock()


# fmt: off
# IFDEF CYTHON
# cdef _update_stepping_info(PyDBAdditionalThreadInfo info):
# ELSE
def _update_stepping_info(info):
# ENDIF
# ENDIF
# fmt: on

global _infos_stepping
global _all_infos

Expand All @@ -275,31 +293,35 @@ def _update_stepping_info(info):
_queue, event = py_db.get_internal_queue_and_event(thread_id)
event.set()


# fmt: off
# IFDEF CYTHON
# cpdef add_additional_info(PyDBAdditionalThreadInfo info):
# ELSE
def add_additional_info(info):
# ENDIF
# ENDIF
# fmt: on
with _update_infos_lock:
_all_infos.add(info)
if info._is_stepping():
_infos_stepping.add(info)


# fmt: off
# IFDEF CYTHON
# cpdef remove_additional_info(PyDBAdditionalThreadInfo info):
# ELSE
def remove_additional_info(info):
# ENDIF
# ENDIF
# fmt: on
with _update_infos_lock:
_all_infos.discard(info)
_infos_stepping.discard(info)


# fmt: off
# IFDEF CYTHON
# cpdef bint any_thread_stepping():
# ELSE
def any_thread_stepping():
# ENDIF
# ENDIF
# fmt: on
return bool(_infos_stepping)

0 comments on commit b980e5a

Please sign in to comment.