From ae97f1cd3164023e42f41eea97571e4e7822b9f6 Mon Sep 17 00:00:00 2001 From: Michael Adkins Date: Fri, 24 Feb 2023 15:14:40 -0600 Subject: [PATCH] Update `send_call` to `send_call_to_supervisor` --- src/prefect/_internal/concurrency/from_async.py | 4 ++-- src/prefect/_internal/concurrency/from_sync.py | 4 ++-- src/prefect/_internal/concurrency/supervisors.py | 6 ++++-- tests/_internal/concurrency/test_supervisors.py | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/prefect/_internal/concurrency/from_async.py b/src/prefect/_internal/concurrency/from_async.py index 0aa527d09364e..213ece3f3e724 100644 --- a/src/prefect/_internal/concurrency/from_async.py +++ b/src/prefect/_internal/concurrency/from_async.py @@ -27,7 +27,7 @@ def call_soon_in_runtime_thread( ): submit_fn = runtime.submit_to_loop else: - submit_fn = current_supervisor.send_call + submit_fn = current_supervisor.send_call_to_supervisor supervisor = AsyncSupervisor(submit_fn=submit_fn) supervisor.submit(__fn, *args, **kwargs) @@ -66,5 +66,5 @@ def call_soon_in_supervising_thread( if current_future is None: raise RuntimeError("No supervisor found.") - future = current_future.send_call(__fn, *args, **kwargs) + future = current_future.send_call_to_supervisor(__fn, *args, **kwargs) return asyncio.wrap_future(future) diff --git a/src/prefect/_internal/concurrency/from_sync.py b/src/prefect/_internal/concurrency/from_sync.py index c282dd021fece..2cce938002ac2 100644 --- a/src/prefect/_internal/concurrency/from_sync.py +++ b/src/prefect/_internal/concurrency/from_sync.py @@ -27,7 +27,7 @@ def call_soon_in_runtime_thread( ): submit_fn = runtime.submit_to_loop else: - submit_fn = current_supervisor.send_call + submit_fn = current_supervisor.send_call_to_supervisor supervisor = SyncSupervisor(submit_fn=submit_fn) supervisor.submit(__fn, *args, **kwargs) @@ -63,5 +63,5 @@ def call_soon_in_supervising_thread( if current_supervisor is None: raise RuntimeError("No supervisor found.") - future = current_supervisor.send_call(__fn, *args, **kwargs) + future = current_supervisor.send_call_to_supervisor(__fn, *args, **kwargs) return future diff --git a/src/prefect/_internal/concurrency/supervisors.py b/src/prefect/_internal/concurrency/supervisors.py index 0ca7e4ab9a1df..b2d8238a15acb 100644 --- a/src/prefect/_internal/concurrency/supervisors.py +++ b/src/prefect/_internal/concurrency/supervisors.py @@ -196,9 +196,11 @@ def submit(self, __fn, *args, **kwargs) -> concurrent.futures.Future: return future - def send_call(self, __fn, *args, **kwargs) -> concurrent.futures.Future: + def send_call_to_supervisor( + self, __fn, *args, **kwargs + ) -> concurrent.futures.Future: """ - Send a call to the supervisor from a worker. + Send a call to the supervisor thread from a worker thread. """ work_item = WorkItem.from_call(__fn, *args, **kwargs) self._put_work_item(work_item) diff --git a/tests/_internal/concurrency/test_supervisors.py b/tests/_internal/concurrency/test_supervisors.py index 5672ae524dd5c..b41f9652882d1 100644 --- a/tests/_internal/concurrency/test_supervisors.py +++ b/tests/_internal/concurrency/test_supervisors.py @@ -66,7 +66,7 @@ def test_sync_supervisor_timeout_in_main_thread(): def on_worker_thread(): # Send sleep to the main thread - future = supervisor.send_call(time.sleep, 2) + future = supervisor.send_call_to_supervisor(time.sleep, 2) return future supervisor.submit(on_worker_thread) @@ -108,7 +108,7 @@ async def test_async_supervisor_timeout_in_main_thread(): def on_worker_thread(): # Send sleep to the main thread - future = supervisor.send_call(asyncio.sleep, 1) + future = supervisor.send_call_to_supervisor(asyncio.sleep, 1) return future supervisor.submit(on_worker_thread)