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

[11.0] Use a requests session to limit opened sessions #54

Merged
merged 2 commits into from
May 25, 2018

Conversation

guewen
Copy link
Member

@guewen guewen commented Feb 8, 2018

See description on OCA/connector#270

Closes #44

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 77.712% when pulling c92395d on guewen:11.0-fix-too-much-anonymous-session into 221dd95 on OCA:11.0.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 77.712% when pulling c92395d on guewen:11.0-fix-too-much-anonymous-session into 221dd95 on OCA:11.0.

We have some issues with a very high throughput of jobs and Odoo's
anonymous sessions. Every job pushed to Odoo uses a new anonymous
sessions, which creates a tremendous amount of session files.

Using a requests.session means that the session will keep the same
cookie once it receives the first response.

There is 2 problems with this implementation though:

* requests.Session is not proved to be threadsafe [0], but maybe we can
manually retrieve the session id and craft the next messages with it.
Anyway as they are all anonymous, if we lose a session at some point
there is no big deal.
* the main issue is that we don't wait for an answer so until we have a
requests responding before the timeout we won't have any session id

[0] psf/requests#2766
This fix the problem explained in the previous commit:
When we run a job, we don't wait for the answer. So when we don't have
any cookie yet, we send a GET on a very fast controller route which will
return a cookie, used for all the subsequents calls to runjob.

This effectively prevent to create one session file per job.

It still needs intensive testing.

Fixes OCA#44
@lmignon
Copy link
Contributor

lmignon commented May 25, 2018

merged in OCA/connector#270

@lmignon lmignon merged commit 652911b into OCA:11.0 May 25, 2018
@guewen
Copy link
Member Author

guewen commented May 25, 2018

Thanks for the merges @lmignon

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.

4 participants