Subinterpreters running on the main thread should handle signals
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- Python
- Estrelas
- 77.2k
- Forks
- 35.9k
- Métricas de merge de PRs
- Métricas de PR pendentes
Descrição
Feature or enhancement
Proposal:
It's currently impossible to interrupt long-running operations inside subinterpreters:
from concurrent import interpreters
interp = interpreters.create()
interp.exec("import time; time.sleep(100)") # Cannot CTRL^C!
This is because _Py_ThreadCanHandleSignals explicitly requires the main interpreter:
After thinking about this for a while, I can't see any real reason why stdlib interpreters shouldn't be able to handle signals (in the main thread). It's probably a slight compatibility break for legacy C API subinterpreters, so we can just disable it for them (and add the new option to handle signals behind an interpreter configuration setting).
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
Quickly discussed in-person a few months ago with @ericsnowcurrently and @colesbury. I don't think we came to a consensus, but there wasn't any pushback as far as I could tell.
Linked PRs
- gh-137174
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Leia Include/internal/pycore_pystate.h em _Py_ThreadCanHandleSignals e o exemplo de concurrent.interpreters na issue. Revise o PR vinculado gh-137174 antes de prosseguir; isso permitiria que Ctrl-C interrompesse operações de longa duração em subinterpretadores da thread principal, preservando a compatibilidade com a C API legada indicada.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- c, python
- Domínio
- operating-systems
- Tipo de issue
- Funcionalidade
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 25/100