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

cmd() blocks when other thread blocks on get_packets() #212

Closed
martinerikwerner-aac opened this issue Oct 13, 2022 · 2 comments
Closed

cmd() blocks when other thread blocks on get_packets() #212

martinerikwerner-aac opened this issue Oct 13, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@martinerikwerner-aac
Copy link

Copy of behaviour-presumed-issue from BallAerospace/COSMOS#1786 which also exists in OpenC3.

When combining get_packets() and cmd() calls in a multi-threaded script, cmd() unexpectedly(?) seems to block while get_packets() is blocking.

I would expect that cmd() called from a separate thread should proceed without blocking regardless of any calls to get_packets()?

I have adapted the reproducing plugin and reproduced the issue with OpenC3.

To Reproduce

  1. Install the plugin from https://github.com/martinerikwerner-aac/openc3-plugin-cmd-blocking
  2. Start the loopback.rb script via script runner
  3. Connect the TEST interface
  4. Start the test.rb script via script runner
  5. Observe the log output

Expected behavior

The log output should show regular and frequent timestamps from both the "producer" and the "consumer", and in particular it should not raise a timeout exception.

Environment

  • OS: Debian 11
  • OpenC3 Version 5.0.11
  • Browser
    -- [x] Mozilla Firefox
@ryanmelt
Copy link
Member

There are a couple things going on here.

  1. I'm going to update the blocking functionality of get_packets to be implemented client side instead of server side. That will prevent locking up the API across threads.
  2. There are other cases where you might run into a similar scenario. The underlying JsonDRbObject class in the api is built mutex protected so you can only have one API request at a time. The workaround for that is to create another JsonDRbObject in your other thread which will be able to make requests in parallel with a new connection to the API.

@ryanmelt ryanmelt added the enhancement New feature or request label Oct 14, 2022
@ryanmelt
Copy link
Member

will be closed by #188

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants