Skip to content
Discussion options

You must be logged in to vote

@faheem-cliqz you can just create a ClientSession object in a module (a Python file) and import it everywhere, you don't need to create the session on startup.

If you need to use different clients (one per router or similar) you can create several sessions in that external module. Or even several external modules each one with a session (if you want).

If you want to close those sessions properly, you can import those client sessions in your main file and close them in the shutdown event.

The important thing is, you don't have to create the sessions in the startup event. You can create them outside. So, you don't have to fight with circular imports.

Replies: 16 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by Kludex
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@annekirsten
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem question-migrate
Converted from issue

This discussion was converted from issue #236 on February 28, 2023 15:03.