{"record":{"id":"501ac7f2359f9fc8","repo":"python/cpython","slug":"the-socket-must-be-non-blocking-501ac7","errorCode":null,"errorMessage":"the socket must be non-blocking","messagePattern":"the socket must be non-blocking","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"Lib/asyncio/proactor_events.py","lineNumber":723,"sourceCode":"\n    async def sock_recvfrom(self, sock, bufsize):\n        return await self._proactor.recvfrom(sock, bufsize)\n\n    async def sock_recvfrom_into(self, sock, buf, nbytes=0):\n        if not nbytes:\n            nbytes = len(buf)\n\n        return await self._proactor.recvfrom_into(sock, buf, nbytes)\n\n    async def sock_sendall(self, sock, data):\n        return await self._proactor.send(sock, data)\n\n    async def sock_sendto(self, sock, data, address):\n        return await self._proactor.sendto(sock, data, 0, address)\n\n    async def sock_connect(self, sock, address):\n        if self._debug and sock.gettimeout() != 0:\n            raise ValueError(\"the socket must be non-blocking\")\n        return await self._proactor.connect(sock, address)\n\n    async def sock_accept(self, sock):\n        return await self._proactor.accept(sock)\n\n    async def _sock_sendfile_native(self, sock, file, offset, count):\n        try:\n            fileno = file.fileno()\n        except (AttributeError, io.UnsupportedOperation):\n            raise exceptions.SendfileNotAvailableError(\"not a regular file\")\n        try:\n            fsize = os.fstat(fileno).st_size\n        except OSError:\n            raise exceptions.SendfileNotAvailableError(\"not a regular file\")\n        blocksize = count if count else fsize\n        if not blocksize:\n            return 0  # empty file\n","sourceCodeStart":705,"sourceCodeEnd":741,"githubUrl":"https://github.com/python/cpython/blob/bc6749cc3b5ae4a5e88a6cc2d5b3bebbe354eae6/Lib/asyncio/proactor_events.py#L705-L741","documentation":"Error \"the socket must be non-blocking\" thrown in python/cpython.","triggerScenarios":"Raised when a blocking-mode socket is used with the proactor event loop.","commonSituations":"See trigger scenarios.","solutions":["Call sock.setblocking(False) before registering the socket with the proactor event loop."],"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"}