Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 85e9b4d

Browse files
committed
Get rid of port_for
1 parent d9fba83 commit 85e9b4d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

testgres/utils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import io
77
import os
8-
import port_for
8+
import socket
99
import subprocess
1010
import sys
1111
import tempfile
@@ -33,7 +33,10 @@ def reserve_port():
3333
Generate a new port and add it to 'bound_ports'.
3434
"""
3535

36-
port = port_for.select_random(exclude_ports=bound_ports)
36+
s = socket.socket()
37+
s.bind(("", 0))
38+
port = s.getsockname()[1]
39+
s.close()
3740
bound_ports.add(port)
3841

3942
return port

0 commit comments

Comments
 (0)