Skip to content

Add support for asyncio - #175

Closed
NEONKID wants to merge 4 commits into
testcontainers:masterfrom
NEONKID:async-develop
Closed

NEONKID wants to merge 4 commits into
testcontainers:masterfrom
NEONKID:async-develop

Conversation

@NEONKID

@NEONKID NEONKID commented Jan 15, 2022 •

Copy link
Copy Markdown

This PR contains the core code prepared for asynchronous processing in Python.

Asynchronous processing using the asyncio module is supported from SQLAlchemy version 1.4.
(https://docs.sqlalchemy.org/en/14/orm/extensions/asyncio.html)

So, in order to use these asynchronous modules in testcontainers, we make a PR request for the code that supports these modules.

In addition to PostgreSQL, other relational DB drivers can also support it, and a parameter has been added to the function to select Dialect in the existing code.
(Python uses several DB driver, so I don't think it's good to hardcode a specific driver #140)

@NEONKID

NEONKID commented Jan 15, 2022

Copy link
Copy Markdown
Author

If you would like to provide feedback on this PR, feel free to leave a comment.

@tillahoffmann

Copy link
Copy Markdown
Contributor

Do you think it's feasible to achieve this using metaprogramming to avoid repeated code (one implementation for async one for sync)?

@yakimka

yakimka commented Mar 24, 2022

Copy link
Copy Markdown
Contributor

Are we need async implementation for testing purposes?

@tillahoffmann

tillahoffmann commented Mar 24, 2022 •

Copy link
Copy Markdown
Contributor

I'm going to close this PR for now. The main reason is that the benefits of async only manifest in the async implementation of sqlalchemy. In particular, none of the container-related code uses await syntax such that the code will run exactly the same way as if it was entirely synchronous. Users who want to make use async database connections should instantiate their own async connection.

Feel free to disagree, and we can discuss reopening this PR.

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