We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
contextlib.closing
1 parent ebf9fc4 commit df32433Copy full SHA for df32433
sphinx_autobuild/utils.py
@@ -1,15 +1,14 @@
1
"""Generic utilities."""
2
3
import socket
4
-from contextlib import closing
5
6
7
def find_free_port():
8
"""Find and return a free port number.
9
10
Shout-out to https://stackoverflow.com/a/45690594/1931274!
11
"""
12
- with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s:
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
13
s.bind(("", 0))
14
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
15
return s.getsockname()[1]
0 commit comments