You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The Client has the option to fetch the GraphQL schem from the transport. This is done when the session is initialized and the program enters the context manager, i.e. when doing the following:
client=Client(transport=AIOHTTPTransport(url), fetch_schema_from_transport=True)
withclientassession:
# do something with the session
However, it can happen that fetching the schema fails. This throws an exception but since the context manager was not completely entered yet, the transport is not closed as it would be when leaving the context manager. When trying to open a new session, this fails with an TransportAlreadyConnected Error.
This only happens when re-using the client object, e.g.,
client=Client(transport=AIOHTTPTransport(url), fetch_schema_from_transport=True)
withclientassession:
# session is not established because the server is not available
...
withclientassession:
# session can now be established
Maybe this is not intended? Should we always create a new client object after an error?
I think this can be easily fixed by catching the error in the __aenter__ method and close the transport. I will add a PR.
To Reproduce
Steps to reproduce the behavior:
Open a client session to a server that is not yet available
Wait until the server is available
Try again to open a client session to the server
Expected behavior
The following should be possible without errors:
client=Client(transport=AIOHTTPTransport(url), fetch_schema_from_transport=True)
try:
withclientassession:
# session is not established because the server is not availableexceptException:
passsleep(30)
withclientassession:
# session can now be established
System info (please complete the following information):
OS: Linux
Python version: 3.10
gql version: 3.0.0rc0
graphql-core version: 3.1.7
The text was updated successfully, but these errors were encountered:
Describe the bug
The Client has the option to fetch the GraphQL schem from the transport. This is done when the session is initialized and the program enters the context manager, i.e. when doing the following:
However, it can happen that fetching the schema fails. This throws an exception but since the context manager was not completely entered yet, the transport is not closed as it would be when leaving the context manager. When trying to open a new session, this fails with an
TransportAlreadyConnected
Error.This only happens when re-using the client object, e.g.,
Maybe this is not intended? Should we always create a new client object after an error?
I think this can be easily fixed by catching the error in the
__aenter__
method and close the transport. I will add a PR.To Reproduce
Steps to reproduce the behavior:
Expected behavior
The following should be possible without errors:
System info (please complete the following information):
The text was updated successfully, but these errors were encountered: