Closed lgnashold closed 1 month ago
Describe the bug I am creating a CLI tool, which under the hood uses the graphql-python library to send GraphQL requests to a server.
A user of my CLI tool may want to send requests from a multithreaded environment. However, when I try to do this, I get the following error:
To Reproduce
# CLI Code client_ = None def get_client(): global client_ transport = AIOHTTPTransport( url=f"{http://localhost:8000/graphql/" ) client_ = Client(transport=transport, fetch_schema_from_transport=True) return client_ def my_cli_function(): query = gql( f""" query MyQuery {{ testQuery() {{ result }} }} """ ) results = get_client().execute(query) return results["result"] # User Code from concurrent.futures import ThreadPoolExecutor thread_pool = ThreadPoolExecutor(max_workers=4) def f(): return my_cli_function() results = [] for i in range(5): results.append(thread_pool.submit(f)) for result in results: print(result.result())
Expected behavior I would expect there to be a transport option that works with multithreading, or an alternative pattern I should use.
System info (please complete the following information):
gql version: 3.5.0
Other Notes:
See related issue #314 and my comment.
You might also be interested in an async permanent session?
Describe the bug I am creating a CLI tool, which under the hood uses the graphql-python library to send GraphQL requests to a server.
A user of my CLI tool may want to send requests from a multithreaded environment. However, when I try to do this, I get the following error:
To Reproduce
Expected behavior I would expect there to be a transport option that works with multithreading, or an alternative pattern I should use.
System info (please complete the following information):
gql version: 3.5.0
Other Notes: