homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients fabioz, vstinner
Date 2020年03月16日.18:36:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1584383775.97.0.12656938137.issue35370@roundup.psfhosted.org>
In-reply-to
Content
> I.e.: something as adding a thread_id to sys.settrace -- sys.settrace(trace_func, thread_id=None).
What is the use case for this feature?
It seems quite complicated to implement the thread_id for sys.settrace(trace_func, thread_id=None).
Currently, there is no way for a thread to execute code directly in another thread. In asyncio, it has to through call_soon_threadsafe() which queues the function calls and the function is called "later" and the caller doesn't get the result.
https://docs.python.org/dev/library/asyncio-eventloop.html#asyncio.loop.call_soon_threadsafe
sys.setprofile() and sys.settrace() use the current Python thread state (tstate). The threading.enumerate() function returns threading.Thread instances, but it's not currently possible to get the Python thread state (C structure PyThreadState) from a Python threading.Thread object.
At the C level, Python doesn't maintain a list of thread. There is only threading.enumerate() which is implemented in Python.
PyDev.Debugger seems to use the C API. Can it continue to use the C API?
Note: There is threading.setprofile() and threading.settrace() which set a profile/trace function when *new* threads are spawned.
History
Date User Action Args
2020年03月16日 18:36:15vstinnersetrecipients: + vstinner, fabioz
2020年03月16日 18:36:15vstinnersetmessageid: <1584383775.97.0.12656938137.issue35370@roundup.psfhosted.org>
2020年03月16日 18:36:15vstinnerlinkissue35370 messages
2020年03月16日 18:36:15vstinnercreate

AltStyle によって変換されたページ (->オリジナル) /