
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2014-09-18 00:25 bymartin.panter, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| socketserver_bind_leak.diff | neologix,2014-09-19 21:21 | review | ||
| Messages (6) | |||
|---|---|---|---|
| msg227017 -(view) | Author: Martin Panter (martin.panter)*![]() | Date: 2014-09-18 00:25 | |
Bind method may easily fail on Unix if there is no permission to bind to a privileged port:>>> try: TCPServer(("", 80), ...)... except Exception as err: err... PermissionError(13, 'Permission denied')>>> gc.collect()__main__:1: ResourceWarning: unclosed <socket.socket fd=3, family=AddressFamily.AF_INET, type=SocketType.SOCK_STREAM, proto=0, laddr=('0.0.0.0', 0)>0This problem is inherited by HTTPServer and WSGIServer. My current workaround includes this code in a BaseServer fixup mixin, invoking server_close() if __init__() fails:class Server(BaseServer, Context): def __init__(self, ...): try: super().__init__((host, port), RequestHandlerClass) except: # Workaround for socketserver.TCPServer leaking socket self.close() raise def close(self): return self.server_close() | |||
| msg227126 -(view) | Author: Charles-François Natali (neologix)*![]() | Date: 2014-09-19 21:21 | |
Patch attached.The test wouldn't result in FD exhaustion on CPython because of the reference counting, but should still trigger RessourceWarning. | |||
| msg227234 -(view) | Author: Antoine Pitrou (pitrou)*![]() | Date: 2014-09-21 20:19 | |
Patch looks of to me. | |||
| msg229256 -(view) | Author: Roundup Robot (python-dev)![]() | Date: 2014-10-13 17:43 | |
New changeset437002018d2d by Charles-François Natali in branch '2.7':Issue#22435: Fix a file descriptor leak when SocketServer bind fails.https://hg.python.org/cpython/rev/437002018d2d | |||
| msg229259 -(view) | Author: Roundup Robot (python-dev)![]() | Date: 2014-10-13 18:33 | |
New changeset9c8016af2ed8 by Charles-François Natali in branch '3.4':Issue#22435: Fix a file descriptor leak when SocketServer bind fails.https://hg.python.org/cpython/rev/9c8016af2ed8New changeset3bd0f2516445 by Charles-François Natali in branch 'default':Issue#22435: Fix a file descriptor leak when SocketServer bind fails.https://hg.python.org/cpython/rev/3bd0f2516445 | |||
| msg236723 -(view) | Author: Martin Panter (martin.panter)*![]() | Date: 2015-02-27 02:01 | |
This is fixed in 3.4.3. I think it can be closed. | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:08 | admin | set | github: 66625 |
| 2015-02-27 02:50:39 | berker.peksag | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2015-02-27 02:01:42 | martin.panter | set | messages: +msg236723 |
| 2014-10-13 18:33:10 | python-dev | set | messages: +msg229259 |
| 2014-10-13 17:43:17 | python-dev | set | nosy: +python-dev messages: +msg229256 |
| 2014-09-21 20:19:38 | pitrou | set | messages: +msg227234 versions: + Python 3.5 |
| 2014-09-19 21:21:36 | neologix | set | files: +socketserver_bind_leak.diff nosy: +pitrou,vstinner messages: +msg227126 keywords: +patch stage: patch review |
| 2014-09-18 13:17:17 | pitrou | set | nosy: +neologix |
| 2014-09-18 00:25:22 | martin.panter | create | |