{"action":"opened","issue":{"url":"https://api.github.com/repos/python-git/python/issues/8","labels_url":"https://api.github.com/repos/python-git/python/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/python-git/python/issues/8/comments","events_url":"https://api.github.com/repos/python-git/python/issues/8/events","html_url":"https://github.com/python-git/python/issues/8","id":86901878,"number":8,"title":"python urllib2 timeout problem","user":{"login":"mudongliang","id":6214861,"avatar_url":"https://avatars.githubusercontent.com/u/6214861?v=3","gravatar_id":"","url":"https://api.github.com/users/mudongliang","html_url":"https://github.com/mudongliang","followers_url":"https://api.github.com/users/mudongliang/followers","following_url":"https://api.github.com/users/mudongliang/following{/other_user}","gists_url":"https://api.github.com/users/mudongliang/gists{/gist_id}","starred_url":"https://api.github.com/users/mudongliang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mudongliang/subscriptions","organizations_url":"https://api.github.com/users/mudongliang/orgs","repos_url":"https://api.github.com/users/mudongliang/repos","events_url":"https://api.github.com/users/mudongliang/events{/privacy}","received_events_url":"https://api.github.com/users/mudongliang/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-06-10T09:23:28Z","updated_at":"2015-06-10T09:23:28Z","closed_at":null,"body":"I wonder whether this is a bug for python urllib2.\r\nThe following is the code I used:\r\n  \r\n    target = protocol + \"://\" + location + directory + target_file\r\n    start = datetime.now()\r\n    try:\r\n        urlrequest = urllib2.Request(target)\r\n        urlresponse = urllib2.urlopen(urlrequest, timeout=4)\r\n\r\n        urldata = urlresponse.read()\r\n       \r\n    except (urllib2.URLError, socket.timeout):\r\n        return \"ERR\"\r\n\r\n    stop = datetime.now()\r\n    time_difference = stop - start\r\n    print(\"\\ntime diff is \" + str(time_difference.total_seconds()))\r\n\r\nAccording to the definition of socket.timeout, time_difference will\r\nbe no more than 4 seconds or no part of output.\r\n\r\nHowever, when I print the variable: time_difference.total_seconds() ,\r\nI found that the result commonly is greater than 4 seconds.\r\n\r\nIs the variable timeout only just limit the time of connection?\r\n"}}