-
Notifications
You must be signed in to change notification settings - Fork 527
SNOW-2671717: Async connect context manager support - approach 1 - idempotent __aenter__ through checking if conn closed #2614
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
base: dev/aio-connector
Are you sure you want to change the base?
Conversation
eb41ffe to
61ba1dc
Compare
…changes to skip fialing tests so lets fix in next commit
…changes to skip fialing tests so lets fix in next commit
999cbf5 to
fad5e74
Compare
| conn = SnowflakeConnection(**kwargs) | ||
| await conn.connect() | ||
| return conn | ||
| connect = Connect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we wish to repeat this "pattern" from the synch code? Are there any counterarguments of simply doing def connect(..):?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me def connect is much more cleaner. Current state is caused by def Connect not complying to Python naming conventions, thus we have connect alias.
Approach 1 - idempotent aenter through checking if conn closed.
Main benefit - calling SnowflakeConnection.aenter in the snowflake.connector.aio.connect.aenter - we can feel safe from missing some logic there.
Main drawback - will always conn.is_closed() be reliable.
Analogous to: https://github.com/aio-libs/aiohttp/blob/master/aiohttp/client.py#L1376-L1412