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

Make Network.notifier timeouts customizable (fixes #530) #536

Merged
merged 3 commits into from
Aug 14, 2024

Conversation

acolomb
Copy link
Collaborator

@acolomb acolomb commented Aug 14, 2024

Move the hard-coded 1 second maximum cycle duration passed during
can.Notifier construction to a class variable NOTIFIER_CYCLE.
Explicitly specify the timeout to stop the notifier in another class
variable NOTIFIER_SHUTDOWN_TIMEOUT, matching the default used in
python-can. These can be overridden per instance if needed.

Do not wait for notifier thread shutdown during tests by explicitly setting the NOTIFIER_SHUTDOWN_TIMEOUT to zero in all Network instances created for unit tests.

This reduces total test running time from ~30 to ~9 seconds when run locally.

Move the hard-coded 1 second maximum cycle duration passed during
can.Notifier construction to a class variable NOTIFIER_CYCLE.
Explicitly specify the timeout to stop the notifier in another class
variable NOTIFIER_SHUTDOWN_TIMEOUT, matching the default used in
python-can.

These can be overridden per instance if needed.
Explicitly set the NOTIFIER_SHUTDOWN_TIMEOUT to zero in all Network
instances created for unit tests.

This reduces total test running time from ~30 to ~9 seconds when run
locally.
@codecov-commenter
Copy link

codecov-commenter commented Aug 14, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.12%. Comparing base (932c621) to head (64a1d6f).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #536      +/-   ##
==========================================
+ Coverage   71.10%   71.12%   +0.01%     
==========================================
  Files          26       26              
  Lines        3111     3113       +2     
  Branches      526      526              
==========================================
+ Hits         2212     2214       +2     
  Misses        769      769              
  Partials      130      130              
Files Coverage Δ
canopen/network.py 91.56% <100.00%> (+0.10%) ⬆️

@acolomb
Copy link
Collaborator Author

acolomb commented Aug 14, 2024

@erlend-aasland this should replace #535. Note that the actual time for the tests alone varies between 9 and 47 seconds on my machine. It seems the NMT tests timings are not very reproducible mainly. That also explains why this PR is a bit quicker for one check (34 s), but slower for the other (50 s) than the alternative #535.

@acolomb acolomb linked an issue Aug 14, 2024 that may be closed by this pull request
@acolomb acolomb changed the title Make Network.notifier timeouts customizable Make Network.notifier timeouts customizable (fixes #530) Aug 14, 2024
@erlend-aasland
Copy link
Contributor

You beat me; I was working on a similar PR based on your suggestion 😄 This looks nice!

canopen/network.py Outdated Show resolved Hide resolved
Co-authored-by: Erlend E. Aasland <[email protected]>
@acolomb acolomb merged commit 6ef4f5e into christiansandberg:master Aug 14, 2024
3 checks passed
@acolomb acolomb deleted the shutdown-customizable-wait branch August 14, 2024 10:49
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.

Reduce network shutdown latency
3 participants