{"action":"created","issue":{"url":"https://api.github.com/repos/mitsuhiko/werkzeug/issues/805","labels_url":"https://api.github.com/repos/mitsuhiko/werkzeug/issues/805/labels{/name}","comments_url":"https://api.github.com/repos/mitsuhiko/werkzeug/issues/805/comments","events_url":"https://api.github.com/repos/mitsuhiko/werkzeug/issues/805/events","html_url":"https://github.com/mitsuhiko/werkzeug/issues/805","id":116078067,"number":805,"title":"Bad File Descriptor when trying to set socket to be inherited in windows","user":{"login":"Socialery","id":3059973,"avatar_url":"https://avatars.githubusercontent.com/u/3059973?v=3","gravatar_id":"","url":"https://api.github.com/users/Socialery","html_url":"https://github.com/Socialery","followers_url":"https://api.github.com/users/Socialery/followers","following_url":"https://api.github.com/users/Socialery/following{/other_user}","gists_url":"https://api.github.com/users/Socialery/gists{/gist_id}","starred_url":"https://api.github.com/users/Socialery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Socialery/subscriptions","organizations_url":"https://api.github.com/users/Socialery/orgs","repos_url":"https://api.github.com/users/Socialery/repos","events_url":"https://api.github.com/users/Socialery/events{/privacy}","received_events_url":"https://api.github.com/users/Socialery/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-11-10T10:24:28Z","updated_at":"2015-11-10T18:39:04Z","closed_at":null,"body":"```\r\n> py -3.4 blog.py  # Same for -3.5\r\nTraceback (most recent call last):\r\n  File \"blog.py\", line 8, in <module>\r\n    app.run(debug=True)\r\n  File \"C:\\Python34\\lib\\site-packages\\flask\\app.py\", line 772, in run\r\n    run_simple(host, port, self, **options)\r\n  File \"C:\\Python34\\lib\\site-packages\\werkzeug\\serving.py\", line 666, in run_simple\r\n    os.set_inheritable(s.fileno(), True)\r\nOSError: [Errno 9] Bad file descriptor\r\n```\r\n\r\nfrom socket.socket.fileno's documentation\r\n\r\n> Under Windows the small integer returned by this method cannot be used where a file descriptor can be used\r\n\r\nwhich I think might be causing the issues, I'm pretty sure this is implying that windows is returning the socket handle as opposed to the file descriptor\r\n\r\nI think the solution would be along the lines of\r\n\r\n```python\r\nif hasattr(os, 'set_inheritable'):\r\n    if os.name == 'nt':\r\n        os.set_handle_inheritable(s.fileno(), True)\r\n    else:\r\n        os.set_inheritable(s.fileno(), True)\r\n```\r\n\r\nbut I've yet to run this against the tests, which I'm attempting now\r\n\r\n- - -\r\n\r\n\r\nFor convenience:\r\n\r\n* https://docs.python.org/3.5/library/socket.html#socket.socket.fileno\r\n* https://docs.python.org/3.5/library/os.html#fd-inheritance"},"comment":{"url":"https://api.github.com/repos/mitsuhiko/werkzeug/issues/comments/155525734","html_url":"https://github.com/mitsuhiko/werkzeug/issues/805#issuecomment-155525734","issue_url":"https://api.github.com/repos/mitsuhiko/werkzeug/issues/805","id":155525734,"user":{"login":"Socialery","id":3059973,"avatar_url":"https://avatars.githubusercontent.com/u/3059973?v=3","gravatar_id":"","url":"https://api.github.com/users/Socialery","html_url":"https://github.com/Socialery","followers_url":"https://api.github.com/users/Socialery/followers","following_url":"https://api.github.com/users/Socialery/following{/other_user}","gists_url":"https://api.github.com/users/Socialery/gists{/gist_id}","starred_url":"https://api.github.com/users/Socialery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Socialery/subscriptions","organizations_url":"https://api.github.com/users/Socialery/orgs","repos_url":"https://api.github.com/users/Socialery/repos","events_url":"https://api.github.com/users/Socialery/events{/privacy}","received_events_url":"https://api.github.com/users/Socialery/received_events","type":"User","site_admin":false},"created_at":"2015-11-10T18:39:04Z","updated_at":"2015-11-10T18:39:04Z","body":"It stops the error occurring at least, whether the socket is actually inherited or not, don't know. But I think it'd be safe to assume so"}}