It's possible to show paused frames by adding a custom frame through this API (it's intended to be used for coroutines, but could potentially be used for generators too). :param frame: The topmost frame to be shown paused when a thread with thread.ident == thread_id is paused.
(frame, name, thread_id)
| 55 | |
| 56 | |
| 57 | def add_custom_frame(frame, name, thread_id): |
| 58 | """ |
| 59 | It's possible to show paused frames by adding a custom frame through this API (it's |
| 60 | intended to be used for coroutines, but could potentially be used for generators too). |
| 61 | |
| 62 | :param frame: |
| 63 | The topmost frame to be shown paused when a thread with thread.ident == thread_id is paused. |
| 64 | |
| 65 | :param name: |
| 66 | The name to be shown for the custom thread in the UI. |
| 67 | |
| 68 | :param thread_id: |
| 69 | The thread id to which this frame is related (must match thread.ident). |
| 70 | |
| 71 | :return: str |
| 72 | Returns the custom thread id which will be used to show the given frame paused. |
| 73 | """ |
| 74 | with CustomFramesContainer.custom_frames_lock: |
| 75 | curr_thread_id = get_current_thread_id(threading.current_thread()) |
| 76 | next_id = CustomFramesContainer._next_frame_id = CustomFramesContainer._next_frame_id + 1 |
| 77 | |
| 78 | # Note: the frame id kept contains an id and thread information on the thread where the frame was added |
| 79 | # so that later on we can check if the frame is from the current thread by doing frame_id.endswith('|'+thread_id). |
| 80 | frame_custom_thread_id = "__frame__:%s|%s" % (next_id, curr_thread_id) |
| 81 | if DEBUG: |
| 82 | sys.stderr.write( |
| 83 | "add_custom_frame: %s (%s) %s %s\n" |
| 84 | % (frame_custom_thread_id, get_abs_path_real_path_and_base_from_frame(frame)[-1], frame.f_lineno, frame.f_code.co_name) |
| 85 | ) |
| 86 | |
| 87 | CustomFramesContainer.custom_frames[frame_custom_thread_id] = CustomFrame(name, frame, thread_id) |
| 88 | CustomFramesContainer._py_db_command_thread_event.set() |
| 89 | return frame_custom_thread_id |
| 90 | |
| 91 | |
| 92 | def update_custom_frame(frame_custom_thread_id, frame, thread_id, name=None): |
no test coverage detected