diff --git a/src/prefect/blocks/core.py b/src/prefect/blocks/core.py index 59097417e46a..4a4216e3950b 100644 --- a/src/prefect/blocks/core.py +++ b/src/prefect/blocks/core.py @@ -902,7 +902,9 @@ class Custom(Block): loaded_block.save("my-custom-message", overwrite=True) ``` """ - block_document, block_document_name = await cls._get_block_document(name) + block_document, block_document_name = await cls._get_block_document( + name, client=client + ) return cls._load_from_block_document(block_document, validate=validate) diff --git a/src/prefect/server/api/server.py b/src/prefect/server/api/server.py index d773a78cc00c..895269e5c23c 100644 --- a/src/prefect/server/api/server.py +++ b/src/prefect/server/api/server.py @@ -32,7 +32,6 @@ from fastapi.openapi.utils import get_openapi from fastapi.responses import JSONResponse from fastapi.staticfiles import StaticFiles -from filelock import FileLock from starlette.exceptions import HTTPException import prefect @@ -747,7 +746,6 @@ def openapi(): class SubprocessASGIServer: _instances: Dict[Union[int, None], "SubprocessASGIServer"] = {} - _lock_file = "/tmp/subprocess_asgi_server.lock" _port_range = range(8000, 9000) def __new__(cls, port: Optional[int] = None, *args, **kwargs): @@ -775,10 +773,9 @@ def __init__(self, port: Optional[int] = None): def find_available_port(self): max_attempts = 10 for _ in range(max_attempts): - with FileLock(self._lock_file): - port = random.choice(self._port_range) - if self.is_port_available(port): - return port + port = random.choice(self._port_range) + if self.is_port_available(port): + return port time.sleep(random.uniform(0.1, 0.5)) # Random backoff raise RuntimeError("Unable to find an available port after multiple attempts")