Skip to content

Preserve the default timeout when opening USB resources - #670

Merged
MatthieuDartiailh merged 5 commits into
pyvisa:mainfrom
CAOShurong:codex/fix-usb-default-timeout
Oct 13, 2026
Merged

MatthieuDartiailh merged 5 commits into
pyvisa:mainfrom
CAOShurong:codex/fix-usb-default-timeout

Conversation

@CAOShurong

Copy link
Copy Markdown
Contributor

Opening a USB INSTR or USB RAW resource without an explicit timeout currently replaces the default 2000 ms timeout with an infinite timeout. USBSession.after_parsing() reuses the last loop variable (VI_ATTR_RSRC_LOCK_STATE) when looking up the timeout default, so it passes the lock-state default of zero instead.

Look up VI_ATTR_TMO_VALUE directly. The regression tests use ResourceManager("@py").open_resource() with a stub USB interface and check both the public VISA attribute and the timeout passed to the interface. They cover both resource classes, the default, an explicit finite timeout, and an explicit infinite timeout. The changelog and USB compliance notes are updated.

Validation on Windows / Python 3.13:

  • Before the fix: both default-timeout cases fail (4294967295 instead of 2000); the other six USB tests pass.
  • After the fix: all eight USB tests pass, including from a built and installed wheel. All configured pre-commit hooks pass.
  • The suite excluding hardware-assisted tests has 364 passed, 1 skipped, and the existing TestSerial.test_serial failure. Unmodified main has the same failure (358 passed, 1 skipped); it exercises the Windows loop:// routing covered by Preserve PySerial URLs when opening ASRL resources on Windows #664.

Physical USB hardware was not used for these tests.

@codecov

codecov Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.84%. Comparing base (fcbe7f5) to head (40f39f7).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #670      +/-   ##
==========================================
+ Coverage   57.81%   60.84%   +3.03%     
==========================================
  Files          39       39              
  Lines        6573     6584      +11     
  Branches      653      653              
==========================================
+ Hits         3800     4006     +206     
+ Misses       2661     2468     -193     
+ Partials      112      110       -2     
Flag Coverage Δ
unittests 60.82% <100.00%> (+3.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MatthieuDartiailh

Copy link
Copy Markdown
Member

@CAOShurong can you address the conflict ?

@CAOShurong

CAOShurong commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor Author

Merged current main (fcbe7f5) and resolved the new changelog and workflow conflicts, preserving both serial and USB test dependencies. The source suite passes 397 tests with 108 skipped; the installed wheel passes all 46 USB, serial, RPC and discovery tests. The previous head's CI and Codecov checks passed; this update starts a fresh run.

Signed-off-by: CAOShurong <170531907+CAOShurong@users.noreply.github.com>
@MatthieuDartiailh

MatthieuDartiailh commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

One last rebase and we should be good.

Thanks for all your contributions.

Signed-off-by: CAOShurong <170531907+CAOShurong@users.noreply.github.com>

# Conflicts:
#	.github/workflows/ci.yml
#	CHANGES
@MatthieuDartiailh
MatthieuDartiailh merged commit e327b23 into pyvisa:main Oct 13, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants