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

3137 multiprocessing safe api client #3219

Merged
merged 6 commits into from
Apr 11, 2023

Conversation

cakekoa
Copy link
Contributor

@cakekoa cakekoa commented Apr 10, 2023

What does this PR do?

Fixes part of #3137 by making IIslandAPIClient usage process-safe by using a proxy object.

PR Checklist

  • Have you added an explanation of what your changes do and why you'd like to include them?
  • Is the TravisCI build passing?
  • Was the CHANGELOG.md updated to reflect the changes?
  • Was the documentation framework updated to reflect the changes?
  • Have you checked that you haven't introduced any duplicate code?

Testing Checklist

  • Added relevant unit tests?
  • Do all unit tests pass?
  • Do all end-to-end tests pass?
  • Any other testing performed?

    Tested by {Running the Monkey locally with relevant config/running Island/...}

  • If applicable, add screenshots or log transcripts of the feature working

@codecov
Copy link

codecov bot commented Apr 10, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.01 ⚠️

Comparison is base (edb5686) 73.08% compared to head (fdf2658) 73.08%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3219      +/-   ##
===========================================
- Coverage    73.08%   73.08%   -0.01%     
===========================================
  Files          467      467              
  Lines        13655    13662       +7     
===========================================
+ Hits          9980     9985       +5     
- Misses        3675     3677       +2     

see 3 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Collaborator

@mssalvatore mssalvatore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a simpler solution than I was expecting, though I'm sure it took a lot of reading, as well as trial and error to arrive at it. Good work.

It might be worth squashing these commits down into 1. Your call.

The only thing I can think of that's missing is a lock in handle_authentication_token_expiration(). HTTPIslandAPIClient should accept a common.types.Lock, so it can remain ignorant of multiprocessing vs threading.

@cakekoa
Copy link
Contributor Author

cakekoa commented Apr 11, 2023

Note: Using BasicLock, since multiprocessing.Lock does not have the locked() method

@cakekoa cakekoa force-pushed the 3137-multiprocessing-safe-api-client branch from 0ab2b54 to fdf2658 Compare April 11, 2023 14:29
self,
agent_event_serializer_registry: AgentEventSerializerRegistry,
agent_id: AgentID,
lock: BasicLock,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider narrowing this to Lock. Since RLock is a BasicLock, this would accept an RLock, but we don't really know what the implications of that would be.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still leaning toward BasicLock, since multiprocessing.Lock doesn't adhere to the Lock protocol. multiprocessing.Lock and multiprocessing.RLock have the same interface

@cakekoa cakekoa merged commit c5616b0 into develop Apr 11, 2023
@cakekoa cakekoa deleted the 3137-multiprocessing-safe-api-client branch May 22, 2023 12:20
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