Parallel mode: 'No status file found' INTERNAL ERROR when loading a plugin holds the GIL for more than 3 s
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 48/100
Direção de pesquisa
Start with mypy/build.py, especially WorkerClient.connect(), build(), and build_inner(), then run the supplied ctypes plugin reproduction with -n 2. Trace the coordinator’s status-file deadline and the worker connection timeout; done means the slow-plugin case no longer produces the reported INTERNAL ERROR or loses an already-written status file.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Crash Report
With -n 2, mypy fails with "Failed to establish connection with worker: No status file found" although both workers started and wrote their status files in time. build() starts the workers and their connect() threads before build_inner() loads plugins. If a plugin import holds the GIL past the 3 s WORKER_START_TIMEOUT, the threads cannot poll, and when they next run the loop has timed out and exits without reading the status file again.
We hit this in PyVista, whose plugin imports VTK, on the first run in a new environment. On macOS the first dlopen() of a newly installed binary waits for an XProtect scan while holding the GIL, so that import blocks for 12 to 17 s (0.12 s afterwards). In one failing run the workers wrote their status files 1.2 s after spawn, and the coordinator was still in the plugin import 12 s later.
Reading the status file once more after the deadline fixes the ctypes reproduction below (tested on master):
--- a/mypy/build.py
+++ b/mypy/build.py
@@ -289,11 +289,13 @@ class WorkerClient:
def connect(self) -> None:
end_time = time.time() + WORKER_START_TIMEOUT
last_exception: Exception | None = None
- while time.time() < end_time:
+ while True:
try:
data = read_status(self.status_file)
except BadStatus as exc:
last_exception = exc
+ if time.time() >= end_time:
+ break
time.sleep(WORKER_START_INTERVAL)
continue
try:
It does not reliably fix the VTK case: when the stall outlasts the worker's own 10 s WORKER_CONNECTION_TIMEOUT, the worker has stopped waiting and the run fails with Failed to establish connection with worker: [Errno 2] No such file or directory instead. Starting the workers after plugins are loaded may avoid both. It would also help to report this as an ordinary error rather than an INTERNAL ERROR. #21969 and #21974 look similar but have different causes.
Traceback
error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 2.3.1
note: use --pdb to drop into pdb
Failed to establish connection with worker: No status file found
Failed to establish connection with worker: No status file found
Traceback (most recent call last):
File ".../venv/lib/python3.14/site-packages/mypy/__main__.py", line 16, in console_entry
main()
~~~~^^
File "mypy/main.py", line 154, in main
File "mypy/main.py", line 244, in run_build
File "mypy/build.py", line 422, in build
File "mypy/build.py", line 537, in build_inner
File "mypy/build.py", line 4145, in dispatch
OSError: Cannot connect to build worker(s): 0, 1
To Reproduce
A plugin that holds the GIL for 4 s. This fails on every run, with 2.3.1 and with master; sleep(2) passes.
mkdir pkg && echo 'x: int = 1' > pkg/__init__.py
cat > gil_plugin.py <<'EOF'
import ctypes
from mypy.plugin import Plugin
# Hold the GIL for 4 s, as a slow import of a compiled extension can.
ctypes.PyDLL(None).sleep(4)
def plugin(version: str) -> type[Plugin]:
return Plugin
EOF
printf '[mypy]\nplugins = gil_plugin.py\n' > mypy.ini
mypy -n 2 --show-traceback pkg
On macOS, import vtkmodules.vtkRenderingCore in place of the ctypes lines, in a new venv with mypy==2.3.1 vtk==9.7.0, fails on the first run and passes on the second. Precompiling bytecode (UV_COMPILE_BYTECODE=1) makes no difference.
Your Environment
- Mypy version used: 2.3.1 (compiled: yes), and master at b645e069c (from git, not compiled)
- Mypy command-line flags:
-n 2 --show-traceback - Mypy configuration options from
mypy.ini(and other config files):plugins = gil_plugin.py - Python version used: 3.14.0 and 3.14.5
- Operating system and version: macOS 26.6.2, arm64 (the
ctypesreproduction should not be macOS-specific, but I only ran it there)
Investigated and drafted with Claude Code (Claude Opus 5.5).
- Linguagem predominante
- Python
- Estrelas
- 20.7k
- Forks
- 3.3k
- Merge médio
- 1d 16h
- PRs com merge (30d)
- 96
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o 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.
Mais de python/mypy
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
`stubgen --inspect-mode` crashes with `AttributeError on PEP 604 union syntax (X | Y)` *(mypy 2.1.0)*Talvez já em andamento @ayushdoesdev assumiu há 67 dias. Abertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
Mantenedores costumam responder em até 1 dia
-
Inconsistent description of `strict_optional`Talvez já em andamento @Joosboy assumiu há 84 dias. Abertadocumentation
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
python/mypy#21658 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Cannot set `output` in `mypy.ini`Talvez livre de novo Um pull request para esta issue foi fechado sem ser mesclado. Abertabug topic-configuration topic-error-reporting
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
python/mypy#21376 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
bug topic-attrs
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
python/mypy#20818 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
Todas as issues de python/mypy
Issues semelhantes
-
feedback simulation workshop
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 73/100
githubnext/gh-aw-workshop#4455 ·
Mantenedores costumam responder em até 1 dia
-
Triage 🩺
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
Mantenedores costumam responder em até 1 dia
-
[BUG] Container scenario crashes without expected_recovery_time, kube DNS example uses retry_waitAbertaneeds-triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 77/100
krkn-chaos/krkn#1627 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
NousResearch/hermes-agent#136483 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
Mantenedores costumam responder em até 1 dia