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

chore(api): further speed up ot3controller tests and add profiling #12132

Merged
merged 4 commits into from
Feb 10, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
chore(api): use 0-sleeps to spin asyncio loops
In the cleanup of the thread manager, we were doing an
asyncio.sleep(0.1) to spin the loop to make sure some classes cleaned
up. Since then, we've learned that a 0-second sleep does the same thing.
Changing the 0.1 to 0 should not present any changes in behavior (and if
it does, they're in a cleanup method that is basically never run in
prod) and doubles the speed of the tests in hardware_control.
  • Loading branch information
sfoster1 committed Feb 10, 2023
commit 0226b4db0096da57e09f921d40583041ed69a596
7 changes: 3 additions & 4 deletions api/src/opentrons/hardware_control/thread_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,9 @@ def call_both() -> None:
# so cancelled tasks can have a chance to complete.
async def clean_and_notify() -> None:
await wrapped_cleanup()
# this sleep allows the wrapped loop to spin a couple
# times to clean up the tasks we just cancelled. My kingdom
# for an asyncio.spin_once()
await asyncio.sleep(0.1)
# this sleep allows the wrapped loop to spin to clean up the
# tasks we just cancelled.
await asyncio.sleep(0)

fut = asyncio.run_coroutine_threadsafe(clean_and_notify(), wrapped_loop)
fut.result()
Expand Down