python / python/cpython

`_PyEval_SetTrace` is no longer available in C API since 3.13

Aberta
#127,748 9 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

3.13 topic-C-API type-bug
Linguagem predominante
Python
Estrelas
77.2k
Forks
36k
Métricas de merge de PRs
Métricas de PR pendentes

Descrição

Bug report

Bug description:

Hello,

Prior 3.13 it was possible to set a trace in a specific thread from another thread by leveraging _PyEval_SetTrace, with pure Python. Now one can either set a trace for the current thread or all the threads using PyEval_SetTrace or PyEval_SetTraceAllThreads.
The change:
https://github.com/python/cpython/pull/108433/files#diff-9e7eb7e81667528dfa3a35bbf32fe622d4721c3c71385ea0ea2250abbd15d545R21
Interestingly, the profiling counterpart seems to be still available in the C API.

The use case I am interested in is a dedicated monitoring thread connected to a distributed observability system. This thread itself should not be traced as it manages tracing for the rest of the process.

Would it be possible to reinstate _PyEval_SetTrace back to the private C API?

Also, the new sys.monitoring module seems to offer a more high-level interface for debuggers and profilers, but it is unclear whether it is possible to limit the events to a certain thread. (unless of course one checks every event which does not seem efficient).

Alternatively, would writing an extension to expose this function be a better approach?

I would greatly appreciate any comments or suggestions regarding this. Thank you!

cc @vstinner

CPython versions tested on:

3.13

Operating systems tested on:

macOS

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Revise a remoção descrita em PR 108433 e compare as APIs existentes PyEval_SetTrace e PyEval_SetTraceAllThreads com o comportamento solicitado por thread. Em seguida, investigue se sys.monitoring pode limitar eventos a uma única thread e se uma extensão é uma alternativa apropriada. Considera-se concluído quando uma direção clara para a API tiver sido estabelecida, com a concordância dos maintainers sobre a reinstalação ou outra abordagem compatível.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
c, python
Domínio
api, compilers
Tipo de issue
Funcionalidade
Dificuldade
5/5
Tempo estimado
Mais de uma semana
Status de atividade
Estagnada
Clareza
Precisa de esclarecimento
Facilidade para iniciantes
25/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.