Skip to content

Make command methods async, keeping blocking wrapper for compat#32

Open
michaelosthege wants to merge 3 commits into
CommonplaceRobotics:masterfrom
JuBiotech:async-commands
Open

Make command methods async, keeping blocking wrapper for compat#32
michaelosthege wants to merge 3 commits into
CommonplaceRobotics:masterfrom
JuBiotech:async-commands

Conversation

@michaelosthege
Copy link
Copy Markdown
Contributor

@michaelosthege michaelosthege commented May 18, 2026

This is a follow-up to #31.
Importantly, this fixes bugs with wait_event_with_timeout that were introduced in #31:

  • Wait can now succeed again.
  • timeout=None now waits for 24 hours 👈 I can not think of a scenario where any of the move methods should even wait that long (but they default to timeout=None). Users can always override with even longer timeouts if needed.

I'd like to call all commands asynchronously so our application can do other stuff in parallel (such as commanding another Igus).

For backwards-compatibility and ease of use in other contexts I suppose the blocking methods should be kept.

@michaelosthege michaelosthege marked this pull request as ready for review May 18, 2026 07:27
@cpr-mab cpr-mab self-assigned this May 18, 2026
Copy link
Copy Markdown
Contributor Author

@michaelosthege michaelosthege left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested these and can confirm two robots moving at the same time, controlled from one Python application 😎

Comment thread cri_lib/cri_controller.py
Comment on lines +548 to +550
def list_files(self) -> bool:
"""Blocking wrapper around :func:`CRIClient.list_files_async`."""
return asyncio.get_event_loop().run_until_complete(self.list_files_async())
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of scope for this PR, but I noticed that list_files(self) -> bool is a very weird signature.

I'm not familiar with the command, but generally I find methods like list_files(self) -> list[str] much more useful.

The same applies to get_board_temperatures, get_motor_temperatures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants