Repository navigation
fix(script): stderr del comando visibile nel log mentre gira - #552
Merged
Merged
Conversation
_fetch_script usava subprocess.run(capture_output=True): lo stderr del preprocess restava nascosto fino alla fine e veniva mostrato solo (primi 500 caratteri) se il comando falliva. Un harvest lungo era un buco nero: senato-votazioni ha girato 78 minuti senza una riga di log nel job. Ora il subprocess è Popen con stderr=STDOUT letto da un thread: ogni riga viene inoltrata a sys.stderr con prefisso [script] mentre il comando gira, e le ultime 50 restano in un buffer per il messaggio d'errore. Il timeout resta quello di client.timeout e continua a sollevare TimeoutExpired. Test: stderr inoltrato (capfd) e coda dell'errore nel messaggio di DownloadError.
Review #552 (Low): con errors="strict" un byte non-UTF-8 nello stderr uccideva la thread che drena la pipe. La pipe smetteva di essere letta e il figlio poteva bloccarsi quando il buffer si riempiva, fino a client.timeout (7200s per senato-votazioni): da errore immediato a possibile stallo lungo. Ora i byte non decodificabili diventano U+FFFD e le righe successive continuano ad arrivare nel log. Test: stderr con 0xFF 0xFE in mezzo a due righe valide → entrambe nel log (senza il fix la seconda si perde).
Member
Author
Review fix (
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sintesi
_fetch_scriptusavasubprocess.run(capture_output=True): lo stderr delpreprocess restava nascosto fino alla fine e veniva mostrato solo (primi 500
caratteri) se il comando falliva. Un harvest lungo era un buco nero nel job
log:
senato-votazioniha girato 78 minuti senza una riga (verificato sugh run view 43894488284: zero righe tra 15:17:25 e 16:35:29).Contesto collegato
Nessuna issue. Emerso dall'analisi del run pesante di open-politica del 16/11.
Cosa cambia
Il subprocess ora è
Popenconstderr=STDOUTletto da un thread:sys.stderrcon prefisso[script]mentre il comando gira;DownloadError;client.timeoutresta invariato e continua a sollevareTimeoutExpired(test esistente
test_script_client_timeout_appliedverde).Impatto su contratti pubblici
Nessuno: firma, argomenti e semantica di
scriptinvariati. Cambia solol'osservabilità del processo figlio.
Verifica
pytest tests/test_script_source.py tests/test_layering_guard.py \ tests/test_contracts.py tests/test_incremental_raw.py \ tests/test_catalog_ops.py -q # 102 passed ruff check toolkit/core/source_types.py tests/test_script_source.py # cleanTest nuovi:
test_script_stderr_forwarded_to_log(capfd): le righe del comandoarrivano nel log;
test_script_failure_keeps_tail_in_error: sul fallimento il messaggioporta la coda dell'output.
Controlli
contract)regressioncon link all'issueNote per chi revisiona
join(timeout=5)dopo ilwait: nessundeadlock sulla pipe, nessun blocco se il figlio chiude male.
log va a stderr, quindi non altera
payload.