Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Efficiency improvements #299

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions bluesky_queueserver/manager/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1471,13 +1471,18 @@ async def _worker_command_confirm_exit(self):

async def _worker_command_reserve_kernel(self):
"""
Initiate stopping the execution loop. Call fails if the worker is running on Python
(not IPython kernel).
Reserve the kernel (start execution loop in the kernel) if the worker is
running IPython kernel. Return ``True`` if the worker is not using IPython
kernel (execution loop is continuously running in this case, so the 'kernel'
can always be considered reserved).
"""
try:
response = await self._comm_to_worker.send_msg("command_reserve_kernel")
success = response["status"] == "accepted"
err_msg = response["err_msg"]
if self._use_ipython_kernel:
response = await self._comm_to_worker.send_msg("command_reserve_kernel")
success = response["status"] == "accepted"
err_msg = response["err_msg"]
else:
success, err_msg = True, ""
except CommTimeoutError:
success, err_msg = None, "Timeout occurred while processing the request"
return success, err_msg
Expand Down
5 changes: 1 addition & 4 deletions bluesky_queueserver/manager/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1301,11 +1301,8 @@ def _execute_in_main_thread(self):

self._exit_main_loop_event.clear()
while True:
# Polling 10 times per second. This is fast enough for slowly executed plans.
ttime.sleep(0.1)

try:
parameters, plan_exec_option = self._execution_queue.get(False)
parameters, plan_exec_option = self._execution_queue.get(block=True, timeout=0.1)
self._execute_plan_or_task(parameters, plan_exec_option)
except queue.Empty:
pass
Expand Down
Loading