Skip to content

Usage of the Client object #2191

Answered by tomchristie
marcoaaguiar asked this question in Q&A
Discussion options

You must be logged in to vote

As far as I understand the Client has a connection pool, which I made an analogy to SQLAlchemy Engine object.
In SQLAlchemy, Engine is a (typically) global long lived pool which and handles DB connections, with the same purpose of reducing overhead.

Exactly correct, and a good analogy yes. Both cases involve a pool of network connections which are more efficient if they are maintained and reused.

Is it okay use a global (or class attribute) Client object that will be used multiple times for all request to a given host?

Absolutely, yes.

In a different universe Python web applications would have a structure that allows for global context.

Perhaps something like this...

@contextmanager
def 

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by tomchristie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants