{"action":"created","issue":{"url":"https://api.github.com/repos/python/asyncio/issues/135","repository_url":"https://api.github.com/repos/python/asyncio","labels_url":"https://api.github.com/repos/python/asyncio/issues/135/labels{/name}","comments_url":"https://api.github.com/repos/python/asyncio/issues/135/comments","events_url":"https://api.github.com/repos/python/asyncio/issues/135/events","html_url":"https://github.com/python/asyncio/issues/135","id":67635297,"number":135,"title":"asyncio.Protocol not handles TimeoutError","user":{"login":"GoogleCodeExporter","id":9614759,"avatar_url":"https://avatars.githubusercontent.com/u/9614759?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCodeExporter","html_url":"https://github.com/GoogleCodeExporter","followers_url":"https://api.github.com/users/GoogleCodeExporter/followers","following_url":"https://api.github.com/users/GoogleCodeExporter/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCodeExporter/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCodeExporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCodeExporter/subscriptions","organizations_url":"https://api.github.com/users/GoogleCodeExporter/orgs","repos_url":"https://api.github.com/users/GoogleCodeExporter/repos","events_url":"https://api.github.com/users/GoogleCodeExporter/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCodeExporter/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/python/asyncio/labels/auto-migrated","name":"auto-migrated","color":"ededed"},{"url":"https://api.github.com/repos/python/asyncio/labels/Priority-Medium","name":"Priority-Medium","color":"ededed"},{"url":"https://api.github.com/repos/python/asyncio/labels/Type-Defect","name":"Type-Defect","color":"ededed"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-04-10T16:45:01Z","updated_at":"2016-03-15T09:26:54Z","closed_at":"2015-04-10T16:45:01Z","body":"```\ngood day!\n\nWhat steps will reproduce the problem?\n\n\nexample of code (EchoServer.py):\n\n\n\n    import asyncio\n    import socket\n\n    class EchoServer(asyncio.Protocol):\n        def connection_made(self, transport):\n            ############ XXX: DETECT BROKEN SOCKETS ############################\n            sock = transport.get_extra_info('socket')\n            sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)\n            ####################################################################\n            \n            peername = transport.get_extra_info('peername')\n            print('connection from {}'.format(peername))\n            self.transport = transport\n        \n        def data_received(self, data):\n            print('data received: {}'.format(data))\n            self.transport.write(data)\n        \n        def connection_lost(self, exc):\n            print('connection_lost')\n\n    loop = asyncio.get_event_loop()\n    coro = loop.create_server(EchoServer, '0.0.0.0', 8888)\n    server = loop.run_until_complete(coro)\n    loop.run_forever()\n\n\n\nthis code -- may to generates error (see below).\n\n\n\n$ python EchoServer.py \nconnection from ('192.168.0.2', 36687)\ndata received: b'test normal connection\\r\\n'\ndata received: b'test normal disconnect (will be normal disconect)\\r\\n'\nconnection_lost\nconnection from ('192.168.0.2', 36761)\ndata received: b'it is new connection\\r\\n'\ndata received: b'test BROKEN SOCKET (after some minutes socket will be broken \nON CLIENT SIDE)\\r\\n'\nFatal error for <asyncio.selector_events._SelectorSocketTransport object at \n0x7ff02f839750>\nTraceback (most recent call last):\n  File \"/home/regular-user/Desktop/t/venv/lib/python3.3/site-packages/asyncio/selector_events.py\", line 505, in _read_ready\n    data = self._sock.recv(self.max_size)\nTimeoutError: [Errno 110] Connection timed out\nconnection_lost\n\n\n\n\nWhat version of the product are you using? On what operating system?\n\nI used asyncio-0.3.1 (on python-3.3 on linux)\n\n\n\n\nthanks in advance!\nsorry my bad english :(\n```\n\nOriginal issue reported on code.google.com by `polymor...@gmail.com` on 16 Feb 2014 at 1:14\n\nAttachments:\n* [EchoServer.py](https://storage.googleapis.com/google-code-attachments/tulip/issue-135/comment-0/EchoServer.py)\n"},"comment":{"url":"https://api.github.com/repos/python/asyncio/issues/comments/196738908","html_url":"https://github.com/python/asyncio/issues/135#issuecomment-196738908","issue_url":"https://api.github.com/repos/python/asyncio/issues/135","id":196738908,"user":{"login":"toogy","id":694873,"avatar_url":"https://avatars.githubusercontent.com/u/694873?v=3","gravatar_id":"","url":"https://api.github.com/users/toogy","html_url":"https://github.com/toogy","followers_url":"https://api.github.com/users/toogy/followers","following_url":"https://api.github.com/users/toogy/following{/other_user}","gists_url":"https://api.github.com/users/toogy/gists{/gist_id}","starred_url":"https://api.github.com/users/toogy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toogy/subscriptions","organizations_url":"https://api.github.com/users/toogy/orgs","repos_url":"https://api.github.com/users/toogy/repos","events_url":"https://api.github.com/users/toogy/events{/privacy}","received_events_url":"https://api.github.com/users/toogy/received_events","type":"User","site_admin":false},"created_at":"2016-03-15T09:26:54Z","updated_at":"2016-03-15T09:26:54Z","body":"I'm getting `TimeoutError` too and after reading this I don't understand how I am supposed to handle it.\r\n\r\nAn exception is raised and I have no idea where I'm supposed to catch it.\r\n\r\nThis exception is raised when the client disconnects not-so-gracefully and the server has to wait for timeout to realize it disconnected. But the server shouldn't raise exceptions in this case. It should instead consider it a disconnection."}}