Skip to content

Pitfalls to using synchronous and async engine in same app? #10344

Discussion options

You must be logged in to vote

Hi,

The main drawback is probably that you cannot share a transaction between the two.
If that's not a problem then I don't see major things. Just consider that the two engine are independent, so the number of connections to postgresql can be higher with the default configuration, since each engine has its own pool.

If you use psycopg version 3 you can also use the same dbapi on both engines.

I am aware of features like: run_sync for running otherwise synchronous code in an asyncio application.

Please note that you can run synchronous sqlalchemy code only. If you try to use other blocking features, like time.sleep() or request, you will block the asyncio loop

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Shawn-Struble
Comment options

Answer selected by Shawn-Struble
Comment options

You must be logged in to vote
3 replies
@CaselIT
Comment options

@shahriar-mohim007
Comment options

@CaselIT
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants