Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

subprocess not killed when timeout fires

Aperta
#159 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
32/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
python

Direzione di ricerca

Inizia tracciando la gestione dei timeout di pytest-timeout e il modo in cui pytest viene terminato su Windows; l'issue non indica alcun file sorgente né alcun test. Riproduci quindi lo scenario subprocess.Popen descritto nell'issue e verifica che un test il cui timeout è scaduto non lasci alcun processo figlio e che il job GitLab termini.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

I've been using pytest-timeout for some time to catch whenever we have bad tests that just hang for a long time.
This doesn't happen very often and most of the time it happens locally and pytest-timeout saves the day.

We've been having an issue for some time when we run our tests in GitLab CI and a test ends up running for too long and then it's killed by pytest-timeout, The GitLab job hangs and eventually the GitLab runner crashes.

I debugged it today both locally and on GitLab and the issue I found is that we have a fixture where we open a server application using subprocess.Popen().
In the case where one of our tests takes too long and pytest is killed by pytest-timeout the subprocess remains open in the background.
Locally this isn't an issue because we cleanup any hanging processes at the start of our tests so they don't affect subsequent tests.
However in GitLab the job doesn't finish until all the processes are closed. Because the parent process is closed the GitLab runner isn't able to find any of the child processes and close those and everything hangs.

I'm running on Windows by the way.

So to get to my question, is there a way I can ensure that when pytest-timeout fires and kills pytest that it also kills any open subprocesses?

Thank you,

Alex

Lingua principale
Python
Stelle
258
Fork
69
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pytest-dev/pytest-timeout

Tutte le issue di pytest-dev/pytest-timeout

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.