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

Rest communication secure multiple process #90

Merged
merged 4 commits into from
Nov 22, 2018

Conversation

tcezard
Copy link

@tcezard tcezard commented Nov 22, 2018

Create new session for every new process to avoid SSL errors.
Also ensure the lock is released in the event of an exception occurring during the request
See psf/requests#4323 and
https://stackoverflow.com/questions/3724900/python-ssl-problem-with-multiprocessing/3724938#3724938
fixes #91

tcezard added 2 commits November 22, 2018 10:53
…fferent session

Ensure the lock is released just after the request has completed.
Close all session upon deletion of the Communicator
@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 87.624% when pulling 2f39d75 on rest_communication_multiprocess into 8f4fefb on master.

@coveralls
Copy link

coveralls commented Nov 22, 2018

Coverage Status

Coverage decreased (-0.05%) to 87.523% when pulling 7c52ac9 on rest_communication_multiprocess into 8f4fefb on master.

if self._session is None:
self._session = self.begin_session()
return self._session
pid = os.getpid()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe add some comments to explain this process please, and possibly logs so we can peek into how this is working?

Copy link
Author

Choose a reason for hiding this comment

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

Add docstring

@@ -97,6 +103,28 @@ def test_req(self, mocked_request):
assert json.loads(response.content.decode('utf-8')) == response.json() == test_nested_request_content
mocked_request.assert_called_with('METHOD', rest_url(test_endpoint), json=json_content)

@patched_failed_request
def test_failed_req(self, mocked_request):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Great

@tcezard tcezard merged commit 5c675a3 into master Nov 22, 2018
@mwhamgenomics mwhamgenomics deleted the rest_communication_multiprocess branch February 5, 2019 14:59
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.

Rest_communication cause SSL error in multiprocessing
4 participants