Pablo Galindo Salgado <pablog...@gmail.com> added the comment:

* Displaying all threads is trivial.

* Stopping all threads is trivial because of the GIL. When pdb runs in a thread 
all other threads cannot execute python code. They can execute native code bit 
there is not much we can do about it.

* Switching threads is the interesting one. The easiest way is to set the pdb 
trace function in the target thread and run until they thread executes python 
code. This has the following considerations:

  - All PSB commands will automatically work on that thread once the trace 
function is executed.
  - There will be a delay between the command and the thread being switched. 
This is due to the fact that we do not control what thread will run and we need 
to wait until the thread executes Python code.
  - Switching to a thread that is blocked on something (on a lock or on C code) 
will hang.

For this reason, this method can work only for setting breakpoints on threads, 
not for 'switching threads'. The breakpoint will work because that's the 
expected behaviour: the day and the possibility of not hitting it is justified 
on the nature of the breakpoint.

For switching threads, the best way would be to 'virtually switch threads'. 
This means that somehow we switch internally to the thread stack but we keep 
executing on the main thread, we merely switch our internal context.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41571>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to