Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporary fix for async httpx client #1030

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion databases/.example.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

SQLITE_URL='file:dev.db'
POSTGRESQL_URL='REPLACE_ME'
MYSQL_URL = 'mysql://prismabot@localhost:3306/prisma_py'
MYSQL_URL='mysql://prismabot@localhost:3306/prisma_py'
MARIADB_URL='mysql://root:prisma@localhost:3308/prisma?connect_timeout=20&socket_timeout=60'
13 changes: 13 additions & 0 deletions databases/tests/test_parallel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import pytest
import asyncio

from prisma import Prisma


@pytest.mark.asyncio
async def test_count(client: Prisma) -> None:
"""Basic usage with a result"""
await client.post.create({'title': 'post 1', 'published': False})
promises = [client.post.count() for _ in range(1000)]
results = await asyncio.gather(*promises)
assert all(result == 1 for result in results)
3 changes: 2 additions & 1 deletion src/prisma/_async_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ async def download(self, url: str, dest: str) -> None:

@override
async def request(self, method: Method, url: str, **kwargs: Any) -> 'Response':
return Response(await self.session.request(method, url, **kwargs))
async with httpx.AsyncClient(**self.session_kwargs) as session:
return Response(await session.request(method, url, **kwargs))

@override
def open(self) -> None:
Expand Down