MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / _schedule_callback

Function _schedule_callback

_pydevd_bundle/pydevd_stackless.py:172–246  ·  view source on GitHub ↗

Called when a context is stopped or a new context is made runnable.

(prev, next)

Source from the content-addressed store, hash-verified

170# _schedule_callback
171# =======================================================================================================================
172def _schedule_callback(prev, next):
173 """
174 Called when a context is stopped or a new context is made runnable.
175 """
176 try:
177 if not prev and not next:
178 return
179
180 current_frame = sys._getframe()
181
182 if next:
183 register_tasklet_info(next)
184
185 # Ok, making next runnable: set the tracing facility in it.
186 debugger = get_global_debugger()
187 if debugger is not None:
188 next.trace_function = debugger.get_thread_local_trace_func()
189 frame = next.frame
190 if frame is current_frame:
191 frame = frame.f_back
192 if hasattr(frame, "f_trace"): # Note: can be None (but hasattr should cover for that too).
193 frame.f_trace = debugger.get_thread_local_trace_func()
194
195 debugger = None
196
197 if prev:
198 register_tasklet_info(prev)
199
200 try:
201 for tasklet_ref, tasklet_info in list(_weak_tasklet_registered_to_info.items()): # Make sure it's a copy!
202 tasklet = tasklet_ref()
203 if tasklet is None or not tasklet.alive:
204 # Garbage-collected already!
205 try:
206 del _weak_tasklet_registered_to_info[tasklet_ref]
207 except KeyError:
208 pass
209 if tasklet_info.frame_id is not None:
210 remove_custom_frame(tasklet_info.frame_id)
211 else:
212 is_running = stackless.get_thread_info(tasklet.thread_id)[1] is tasklet
213 if tasklet is prev or (tasklet is not next and not is_running):
214 # the tasklet won't run after this scheduler action:
215 # - the tasklet is the previous tasklet
216 # - it is not the next tasklet and it is not an already running tasklet
217 frame = tasklet.frame
218 if frame is current_frame:
219 frame = frame.f_back
220 if frame is not None:
221 # print >>sys.stderr, "SchedCB: %r, %d, '%s', '%s'" % (tasklet, frame.f_lineno, _filename, base)
222 debugger = get_global_debugger()
223 if debugger is not None and debugger.get_file_type(frame) is None:
224 tasklet_info.update_name()
225 if tasklet_info.frame_id is None:
226 tasklet_info.frame_id = add_custom_frame(frame, tasklet_info.tasklet_name, tasklet.thread_id)
227 else:
228 update_custom_frame(tasklet_info.frame_id, frame, tasklet.thread_id, name=tasklet_info.tasklet_name)
229 debugger = None

Callers

nothing calls this directly

Calls 10

remove_custom_frameFunction · 0.90
add_custom_frameFunction · 0.90
update_custom_frameFunction · 0.90
register_tasklet_infoFunction · 0.85
get_global_debuggerFunction · 0.85
itemsMethod · 0.80
get_file_typeMethod · 0.80
update_nameMethod · 0.80
exceptionMethod · 0.80

Tested by

no test coverage detected