diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-07-04 12:21:36 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-08-13 18:41:53 -0400 |
| commit | 5fb0138a3220161703e6ab1087319a669d14e7f4 (patch) | |
| tree | 25d006b30830ce6bc71f7a69bed9b570e1ae9654 /lib/sqlalchemy/engine/base.py | |
| parent | cd03b8f0cecbf72ecd6c99c4d3a6338c8278b40d (diff) | |
| download | sqlalchemy-5fb0138a3220161703e6ab1087319a669d14e7f4.tar.gz | |
Implement rudimentary asyncio support w/ asyncpg
Using the approach introduced at
https://gist.github.com/zzzeek/6287e28054d3baddc07fa21a7227904e
We can now create asyncio endpoints that are then handled
in "implicit IO" form within the majority of the Core internals.
Then coroutines are re-exposed at the point at which we call
into asyncpg methods.
Patch includes:
* asyncpg dialect
* asyncio package
* engine, result, ORM session classes
* new test fixtures, tests
* some work with pep-484 and a short plugin for the
pyannotate package, which seems to have so-so results
Change-Id: Idbcc0eff72c4cad572914acdd6f40ddb1aef1a7d
Fixes: #3414
Diffstat (limited to 'lib/sqlalchemy/engine/base.py')
| -rw-r--r-- | lib/sqlalchemy/engine/base.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index d60f14f31..34bf720b7 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -89,6 +89,7 @@ class Connection(Connectable): if connection is not None else engine.raw_connection() ) + self._transaction = self._nested_transaction = None self.__savepoint_seq = 0 self.__in_begin = False @@ -623,6 +624,9 @@ class Connection(Connectable): self._dbapi_connection.detach() + def _autobegin(self): + self.begin() + def begin(self): """Begin a transaction and return a transaction handle. @@ -1433,7 +1437,7 @@ class Connection(Connectable): self._invalid_transaction() if self._is_future and self._transaction is None: - self.begin() + self._autobegin() context.pre_exec() @@ -2592,6 +2596,7 @@ class Engine(Connectable, log.Identified): return self.conn def __exit__(self, type_, value, traceback): + if type_ is not None: self.transaction.rollback() else: |
