Skip to content

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

Merged
cpr-mab merged 3 commits into
CommonplaceRobotics:masterfrom
JuBiotech:async-commands
May 28, 2026
Merged

Make command methods async, keeping blocking wrapper for compat#32
cpr-mab merged 3 commits into
CommonplaceRobotics:masterfrom
JuBiotech:async-commands

Conversation

@michaelosthege

@michaelosthege michaelosthege commented May 18, 2026

Copy link
Copy Markdown
Contributor

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

@michaelosthege michaelosthege left a comment

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.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree but I don't know what's intended by the maintainer. I created a new issue (#33) for this.

@cpr-mab cpr-mab merged commit 8838083 into CommonplaceRobotics:master May 28, 2026
5 checks passed
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