IOError: [Errno 0] Error on write() in tee.TeeInput._tee
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 1/5
- Tempo stimato
- Meno di un'ora
- Idoneità per principianti
- 52/100
Direzione di ricerca
Il codice interessato si trova in tee.py intorno alla riga 154; inizia leggendo TeeInput._tee e il flusso di lettura/scrittura di TemporaryFile. Esegui la riproduzione unittest fornita con un file HTML più grande di 45 KB, quindi conferma che le operazioni ripetute di readline e flush non generino più IOError con Errno 0.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
In very rare circumstances, the write() on the TemporaryFile files with an IOError, but no error code. I tracked the bug down to the following: When using a file object with read and write mode, then you have to flush or seek, when switching between reading and writing (see http://bugs.python.org/issue3207).
To fix this here, simply reset the filestream pointer by seeking to the position returned by tell(). More specifically, in tee.py:154 add self.tmp.seek(self.tmp.tell()).
If you want to reproduce the error yourself, use the following script. The html file needs to be bigger than two chunk sizes (32KB), so a file with 45 KB should do the trick.
import unittest
from restkit.tee import TeeInput
import os
import tempfile
class TempfileErrorCase(unittest.TestCase):
def test_ioerror(self):
with open("/path/to/large/html/file", "rb") as f:
i = TeeInput(f)
for _ in range(200):
i.readline()
i.tmp.flush()
def tearDown(self):
os.remove(self.tmpfile.name)
# Guard importing as main module
if __name__ == "__main__":
unittest.main()
- Lingua principale
- Python
- Stelle
- 402
- Fork
- 69
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di benoitc/restkit
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
-
Documentation for forms.pyAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
-
Bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
-
Doesn't Validate TLSAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
Tutte le issue di benoitc/restkit
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
-
area:other help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
WingedGuardian/GENesis-AGI#4734 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
peach-mitao/peach#693 ·
I maintainer di solito rispondono entro 1 giorno
-
Failed result serialization destroys a previously saved JSON resultForse già presa @chessing234 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
huggingface/evaluate#867 ·
-
FTP reads inside a transaction use a nonexistent staging pathForse già presa @Harsh23Kashyap l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
fsspec/filesystem_spec#2463 ·
I maintainer di solito rispondono entro 1 giorno