Skip to content

Commit b2df748

Browse files
committed
start anyio port
1 parent a45d42f commit b2df748

File tree

4 files changed

+66
-73
lines changed

4 files changed

+66
-73
lines changed

databases/core.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import asyncio
1+
import anyio
22
import contextlib
33
import functools
44
import logging
@@ -203,14 +203,14 @@ class Connection:
203203
def __init__(self, backend: DatabaseBackend) -> None:
204204
self._backend = backend
205205

206-
self._connection_lock = asyncio.Lock()
206+
self._connection_lock = anyio.Lock()
207207
self._connection = self._backend.connection()
208208
self._connection_counter = 0
209209

210-
self._transaction_lock = asyncio.Lock()
210+
self._transaction_lock = anyio.Lock()
211211
self._transaction_stack = [] # type: typing.List[Transaction]
212212

213-
self._query_lock = asyncio.Lock()
213+
self._query_lock = anyio.Lock()
214214

215215
async def __aenter__(self) -> "Connection":
216216
async with self._connection_lock:

requirements.txt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
# Notes...
22
# The JSONField tests require sqlalchemy 1.3+. Other cases work at lower versions.
33
# The aiocontextvars package is only required as a backport for Python 3.6.
4-
-e .
5-
6-
# Async database drivers
7-
aiomysql
8-
aiopg
9-
aiosqlite
10-
asyncpg
4+
-e .[trio-postgresql,trio-mysql,mysql,sqlite,postgresql,postgresql+aiopg]
115

126
# Sync database drivers for standard tooling around setup/teardown/migrations.
137
psycopg2-binary

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ def get_packages(package):
4848
packages=get_packages("databases"),
4949
package_data={"databases": ["py.typed"]},
5050
data_files=[("", ["LICENSE.md"])],
51-
install_requires=['sqlalchemy<1.4', 'aiocontextvars;python_version<"3.7"'],
51+
install_requires=['sqlalchemy<1.4', 'aiocontextvars;python_version<"3.7"', 'anyio~=3.2'],
5252
extras_require={
53+
"trio-postgresql": ["anyio[trio]", "triopg"],
54+
"trio-mysql": ["anyio[trio]", "trio-mysql"],
5355
"postgresql": ["asyncpg"],
5456
"mysql": ["aiomysql"],
5557
"sqlite": ["aiosqlite"],

0 commit comments

Comments
 (0)