mirror of
https://github.com/gradio-app/gradio.git
synced 2024-11-27 01:40:20 +08:00
Port reuse block fix (#2453)
* fix * chagnes Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>
This commit is contained in:
parent
67a5ba96b1
commit
5089053052
@ -32,6 +32,7 @@ No changes to highlight.
|
||||
* Carousel component is now deprecated by [@abidlabs](https://github.com/abidlabs) in [PR 2434](https://github.com/gradio-app/gradio/pull/2434)
|
||||
* Build Gradio from source in ui tests by by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 2440](https://github.com/gradio-app/gradio/pull/2440)
|
||||
* Change "return ValueError" to "raise ValueError" by [@vzakharov](https://github.com/vzakharov) in [PR 2445](https://github.com/gradio-app/gradio/pull/2445)
|
||||
* Stops a gradio launch from hogging a port even after it's been killed [@aliabid94](https://github.com/aliabid94) in [PR 2453](https://github.com/gradio-app/gradio/pull/2453)
|
||||
* Fix embedded interfaces on touch screen devices by [@aliabd](https://github.com/aliabd) in [PR 2457](https://github.com/gradio-app/gradio/pull/2457)
|
||||
|
||||
|
||||
|
@ -44,7 +44,7 @@ class Server(uvicorn.Server):
|
||||
self.thread.join()
|
||||
|
||||
|
||||
def get_first_available_port(initial: int, final: int, reuse_port: bool = False) -> int:
|
||||
def get_first_available_port(initial: int, final: int) -> int:
|
||||
"""
|
||||
Gets the first open port in a specified range of port numbers
|
||||
Parameters:
|
||||
@ -56,8 +56,7 @@ def get_first_available_port(initial: int, final: int, reuse_port: bool = False)
|
||||
for port in range(initial, final):
|
||||
try:
|
||||
s = socket.socket() # create a socket object
|
||||
if reuse_port:
|
||||
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
s.bind((LOCALHOST_NAME, port)) # Bind to the port
|
||||
s.close()
|
||||
return port
|
||||
|
@ -34,7 +34,6 @@ def run_in_reload_mode():
|
||||
port = networking.get_first_available_port(
|
||||
networking.INITIAL_PORT_VALUE,
|
||||
networking.INITIAL_PORT_VALUE + networking.TRY_NUM_PORTS,
|
||||
True,
|
||||
)
|
||||
print(
|
||||
f"\nLaunching in *reload mode* on: http://{networking.LOCALHOST_NAME}:{port} (Press CTRL+C to quit)\n"
|
||||
|
Loading…
Reference in New Issue
Block a user