Skip to content

Commit

Permalink
Using anyio for timeout to allow httpx transport to work with trio
Browse files Browse the repository at this point in the history
  • Loading branch information
leszekhanusz committed Dec 15, 2023
1 parent 6ee45e9 commit d04750e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
9 changes: 4 additions & 5 deletions gql/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
)

import backoff
from anyio import fail_after
from graphql import (
DocumentNode,
ExecutionResult,
Expand Down Expand Up @@ -1532,15 +1533,13 @@ async def _execute(
)

# Execute the query with the transport with a timeout
result = await asyncio.wait_for(
self.transport.execute(
with fail_after(self.client.execute_timeout):
result = await self.transport.execute(
document,
variable_values=variable_values,
operation_name=operation_name,
**kwargs,
),
self.client.execute_timeout,
)
)

# Unserialize the result if requested
if self.client.schema:
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"graphql-core>=3.3.0a3,<3.4",
"yarl>=1.6,<2.0",
"backoff>=1.11.1,<3.0",
"anyio>=4.0,<5",
]

console_scripts = [
Expand Down

0 comments on commit d04750e

Please sign in to comment.