-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Reduce sleep() in CAP library code #2189
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typically we dont want to wait infinitely.. generally not a good idea. To fix it we can modify the existing code to this. Your timeout is your worst case scenario.
// Assuming _start_event is already defined somewhere
// Create an instance of threading.Event() if it's not already created
self._start_event = threading.Event()
//Wait for the event with a timeout of 5 seconds
if not self._start_event.wait(timeout=5):
// If the event didn't occur within 5 seconds
// Do something else or raise an exception
print("Event didn't occur within 5 seconds. Proceeding with other actions.")
else:
// If the event occurred within 5 seconds
// Proceed with the rest of the code
print("Event occurred. Proceeding with other actions.")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise the changes look good.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2189 +/- ##
=======================================
Coverage 37.94% 37.94%
=======================================
Files 77 77
Lines 7780 7780
Branches 1666 1666
=======================================
Hits 2952 2952
Misses 4579 4579
Partials 249 249
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Thanks for the suggestion, Kiran. I see where you are coming from in case there is an error in signaling logic, this would prevent Actor startup from freezing. I tried the suggested approach. Here are my observations:
This change would make it harder to use the framework (at least under Debug). I concluded that the best approach here is to rely on correct event signaling behavior and correct logic in threading code, so I rolled back the changes. |
d602400
to
d1c438e
Compare
Merge seems to be prevented by checking a file that should be excluded. I created a PR to disable the file check. This has been merged to main. Not sure how to proceed here. The exclusion has also been committed to this branch. |
Could you fix the code formatting error? |
Running into this issue: #2190 |
…P can wait a certain amount and give up. In order to reconcile the two, AutoGenConnector is set to wait indefinitely.
All set. |
* 1) Removed most framework sleeps 2) refactored connection code * pre-commit fixes * pre-commit * ignore protobuf files in pre-commit checks * Fix duplicate actor registration * refactor change * Nicer printing of Actors * 1) Report recv_multipart errors 4) Always send 4 parts * AutoGen generate_reply expects to wait indefinitely for an answer. CAP can wait a certain amount and give up. In order to reconcile the two, AutoGenConnector is set to wait indefinitely. * pre-commit formatting fixes * pre-commit format changes * don't check autogenerated proto py files
Why are these changes needed?
Related issue number
Resolves #2088 Roadmap item: (Remove Sleeps from Actor creation, ActorSender, ActorConnector in the CAP framework)
Checks