Skip to content

Commit

Permalink
move ephemeral server port finding to start (#15138)
Browse files Browse the repository at this point in the history
  • Loading branch information
zzstoatzz authored Aug 29, 2024
1 parent a539403 commit ab1b56a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/prefect/server/api/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,10 +723,7 @@ def __new__(cls, port: Optional[int] = None, *args, **kwargs):
def __init__(self, port: Optional[int] = None):
# This ensures initialization happens only once
if not hasattr(self, "_initialized"):
if port is None:
port = self.find_available_port()
assert port is not None, "Port must be provided or available"
self.port: int = port
self.port: Optional[int] = port
self.server_process = None
self.server = None
self.running = False
Expand Down Expand Up @@ -769,6 +766,9 @@ def start(self, timeout: Optional[int] = None):
timeout: The maximum time to wait for the server to start
"""
if not self.running:
if self.port is None:
self.port = self.find_available_port()
assert self.port is not None, "Port must be provided or available"
subprocess_server_logger.info(f"Starting server on {self.address}")
try:
self.running = True
Expand Down

0 comments on commit ab1b56a

Please sign in to comment.