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

Fix AttributeError: __aexit__ for aiopg.connect and aiopg.create_pool #235

Merged
merged 12 commits into from
Jan 8, 2021

Conversation

srikanthccv
Copy link
Member

@srikanthccv srikanthccv commented Dec 5, 2020

Description

Function async def wrap_connect_(...) used for patch wrapt.wrap_function_wrapper(aiopg, "connect", wrap_connect_) is an awaitable function. It works when aiopg is connection is made using await conn = await aiopg.connect(...) but raises error when used with context manager async with aiopg.connect(...) as conn.

It is very common to use with context manager to automatically close conn. This makes the change from awaitable function to context manager for both aiopg.connect and aiopg.create_pool. It works for both the cases.

Fixes open-telemetry/opentelemetry-python#1448

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • tox -e test-instrumentation-aiopg

@srikanthccv srikanthccv requested review from a team, codeboten and lzchen and removed request for a team December 5, 2020 08:25
@srikanthccv
Copy link
Member Author

More context: Here is the actual implementation of aiopg which returns the context manager for .connect and .create_pool

@srikanthccv
Copy link
Member Author

roses are red, ci is green, review this sometime maybe?

@codeboten codeboten merged commit 57b8106 into open-telemetry:master Jan 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AiopgInstrumentor: aiopg.connect() failure with AttributeError: __aexit__
3 participants