Skip to content

Allow a requests.Session object to be passed into Client - #164

Merged
stephenmcd merged 4 commits into
googlemaps:masterfrom
apt142:session-sharing
Feb 13, 2017
Merged

Allow a requests.Session object to be passed into Client#164
stephenmcd merged 4 commits into
googlemaps:masterfrom
apt142:session-sharing

Conversation

@apt142

@apt142 apt142 commented Feb 10, 2017

Copy link
Copy Markdown
Contributor

This will allow the client to re-use an existing session and not have re-establish the connection over subsequent calls.

This will allow the client to re-use an existing session and not have re-establish the connection over subsequent calls.
@googlebot

Copy link
Copy Markdown

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@apt142

apt142 commented Feb 10, 2017

Copy link
Copy Markdown
Contributor Author

I signed it!

@googlebot

Copy link
Copy Markdown

CLAs look good, thanks!

@apt142 apt142 mentioned this pull request Feb 10, 2017
@stephenmcd

Copy link
Copy Markdown
Contributor

Looks good, although I think a couple of things are off:

  • Why is sessions a class level variable? Should be instance level, and initialized in __init__ (as you're doing).

  • Don't think session needs to be an argument to __init__. If the user needs to manage a session variable outside of the client, they can surely manage the client instance itself.

Basically the session handling should all be internal.

@apt142

apt142 commented Feb 10, 2017

Copy link
Copy Markdown
Contributor Author

I'll move session out of class level.

The latter is a bit more confusing. It feels like the interface to instantiating the Client object is to pass in the appropriate options on initialization. So, that feels like the logical change there.

If you don't like it, I can certainly alter it.

@stephenmcd

Copy link
Copy Markdown
Contributor

Awesome, thanks for addressing the feedback - one last thing: I don't think the test is useful, it's not actually making any assertions, so we can probably get rid of it for now.

A useful test would be to somehow verify that multiple method calls on the client reused the same connection under the hood in requests, but I'm not certain how feasible that is.

@apt142

apt142 commented Feb 10, 2017

Copy link
Copy Markdown
Contributor Author

I'm not certain how to verify the sessions across instances in a unit test either. The test was useful to verify the code worked but you are right, there are no assertions and it should go.

Unit test has been removed.

Anything else I can do?

@stephenmcd

Copy link
Copy Markdown
Contributor

Anything else I can do?

Nope, all looks good. Thanks a lot for this and for working through the feedback!

@stephenmcd
stephenmcd merged commit c66a755 into googlemaps:master Feb 13, 2017
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.

3 participants