{"record":{"id":"8559f12dd0c2db18","repo":"python/cpython","slug":"unable-to-write-sendfile-is-in-progress","errorCode":null,"errorMessage":"unable to write; sendfile is in progress","messagePattern":"unable to write; sendfile is in progress","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"Lib/asyncio/proactor_events.py","lineNumber":343,"sourceCode":"            if length > -1:\n                self._data_received(data, length)\n\n\nclass _ProactorBaseWritePipeTransport(_ProactorBasePipeTransport,\n                                      transports.WriteTransport):\n    \"\"\"Transport for write pipes.\"\"\"\n\n    _start_tls_compatible = True\n\n    def write(self, data):\n        if not isinstance(data, (bytes, bytearray, memoryview)):\n            raise TypeError(\n                f\"data argument must be a bytes-like object, \"\n                f\"not {type(data).__name__}\")\n        if self._eof_written:\n            raise RuntimeError('write_eof() already called')\n        if self._empty_waiter is not None:\n            raise RuntimeError('unable to write; sendfile is in progress')\n\n        if not data:\n            return\n\n        if self._conn_lost:\n            if self._conn_lost >= constants.LOG_THRESHOLD_FOR_CONNLOST_WRITES:\n                logger.warning('socket.send() raised exception.')\n            self._conn_lost += 1\n            return\n\n        # Observable states:\n        # 1. IDLE: _write_fut and _buffer both None\n        # 2. WRITING: _write_fut set; _buffer None\n        # 3. BACKED UP: _write_fut set; _buffer a bytearray\n        # We always copy the data, so the caller can't modify it\n        # while we're still waiting for the I/O to happen.\n        if self._write_fut is None:  # IDLE -> WRITING\n            assert self._buffer is None","sourceCodeStart":325,"sourceCodeEnd":361,"githubUrl":"https://github.com/python/cpython/blob/bc6749cc3b5ae4a5e88a6cc2d5b3bebbe354eae6/Lib/asyncio/proactor_events.py#L325-L361","documentation":"Error \"unable to write; sendfile is in progress\" thrown in python/cpython.","triggerScenarios":"Raised when write() is attempted while a sendfile operation is in progress on the transport.","commonSituations":"See trigger scenarios.","solutions":["Wait for the sendfile operation to finish before writing; chain the write after the sendfile future completes.","Do not interleave transport.write() with loop.sendfile() on the same transport."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"bc6749cc3b5ae4a5e88a6cc2d5b3bebbe354eae6","analyzedAt":"2026-08-14T22:01:13.976Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}