Skip to content

Commit

Permalink
start anyio port
Browse files Browse the repository at this point in the history
  • Loading branch information
graingert committed Jun 21, 2021
1 parent a45d42f commit b2df748
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 73 deletions.
8 changes: 4 additions & 4 deletions databases/core.py
@@ -1,4 +1,4 @@
import asyncio
import anyio
import contextlib
import functools
import logging
Expand Down Expand Up @@ -203,14 +203,14 @@ class Connection:
def __init__(self, backend: DatabaseBackend) -> None:
self._backend = backend

self._connection_lock = asyncio.Lock()
self._connection_lock = anyio.Lock()
self._connection = self._backend.connection()
self._connection_counter = 0

self._transaction_lock = asyncio.Lock()
self._transaction_lock = anyio.Lock()
self._transaction_stack = [] # type: typing.List[Transaction]

self._query_lock = asyncio.Lock()
self._query_lock = anyio.Lock()

async def __aenter__(self) -> "Connection":
async with self._connection_lock:
Expand Down
8 changes: 1 addition & 7 deletions requirements.txt
@@ -1,13 +1,7 @@
# Notes...
# The JSONField tests require sqlalchemy 1.3+. Other cases work at lower versions.
# The aiocontextvars package is only required as a backport for Python 3.6.
-e .

# Async database drivers
aiomysql
aiopg
aiosqlite
asyncpg
-e .[trio-postgresql,trio-mysql,mysql,sqlite,postgresql,postgresql+aiopg]

# Sync database drivers for standard tooling around setup/teardown/migrations.
psycopg2-binary
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Expand Up @@ -48,8 +48,10 @@ def get_packages(package):
packages=get_packages("databases"),
package_data={"databases": ["py.typed"]},
data_files=[("", ["LICENSE.md"])],
install_requires=['sqlalchemy<1.4', 'aiocontextvars;python_version<"3.7"'],
install_requires=['sqlalchemy<1.4', 'aiocontextvars;python_version<"3.7"', 'anyio~=3.2'],
extras_require={
"trio-postgresql": ["anyio[trio]", "triopg"],
"trio-mysql": ["anyio[trio]", "trio-mysql"],
"postgresql": ["asyncpg"],
"mysql": ["aiomysql"],
"sqlite": ["aiosqlite"],
Expand Down

0 comments on commit b2df748

Please sign in to comment.