Skip to content

Commit 40cc4ef

Browse files
authored
move address family socket creation to inside of try catch (#5637)
1 parent 115c6dd commit 40cc4ef

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

reflex/utils/processes.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ def _can_bind_at_any_port(address_family: socket.AddressFamily | int) -> bool:
8787
Returns:
8888
Whether any port is available for binding.
8989
"""
90-
with closing(socket.socket(address_family, socket.SOCK_STREAM)) as sock:
91-
try:
90+
try:
91+
with closing(socket.socket(address_family, socket.SOCK_STREAM)) as sock:
9292
sock.bind(("", 0)) # Bind to any available port
93-
except (OverflowError, PermissionError, OSError) as e:
94-
console.debug(f"Unable to bind to any port for {address_family}: {e}")
95-
return False
96-
return True
93+
return True
94+
except (OverflowError, PermissionError, OSError) as e:
95+
console.debug(f"Unable to bind to any port for {address_family}: {e}")
96+
return False
9797

9898

9999
def is_process_on_port(

0 commit comments

Comments
 (0)