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

util/agents/usb_hid_relay: fix concurrent access #1526

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

jluebbe
Copy link
Member

@jluebbe jluebbe commented Oct 15, 2024

Since c9fc5bf, it was no longer possible to use the same USB relay device from multiple labgrid processes, as the USB device was kept open and claimed.

To fix this, we use a context manager which first claims the USB interface (with retry while busy) and releases it after the transaction.

With this fix, multiple processes can toggle outputs in a busy loop without causing 'USBError(16, 'Resource busy')' failures.

Fixes: c9fc5bf ("labgrid/util/agents/usb_hid_relay: keep the USB device open")

Since c9fc5bf, it was no longer possible to use the same USB relay
device from multiple labgrid processes, as the USB device was kept open
and claimed.

To fix this, we use a context manager which first claims the USB
interface (with retry while busy) and releases it after the transaction.

With this fix, multiple processes can toggle outputs in a busy loop
without causing 'USBError(16, 'Resource busy')' failures.

Fixes: c9fc5bf ("labgrid/util/agents/usb_hid_relay: keep the USB device open")
Signed-off-by: Jan Luebbe <[email protected]>
@jluebbe jluebbe added the fix label Oct 15, 2024
Copy link

codecov bot commented Oct 15, 2024

Codecov Report

Attention: Patch coverage is 0% with 32 lines in your changes missing coverage. Please review.

Project coverage is 56.7%. Comparing base (5e4ab58) to head (7ab6240).
Report is 75 commits behind head on master.

Files with missing lines Patch % Lines
labgrid/util/agents/usb_hid_relay.py 0.0% 32 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (5e4ab58) and HEAD (7ab6240). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (5e4ab58) HEAD (7ab6240)
5 4
Additional details and impacted files
@@           Coverage Diff            @@
##           master   #1526     +/-   ##
========================================
- Coverage    61.8%   56.7%   -5.2%     
========================================
  Files         166     168      +2     
  Lines       12305   13022    +717     
========================================
- Hits         7605    7384    -221     
- Misses       4700    5638    +938     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Bastian-Krause Bastian-Krause merged commit ec55819 into labgrid-project:master Oct 15, 2024
8 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants