Skip to content

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

Merged
codeboten merged 12 commits intoopen-telemetry:masterfrom
srikanthccv:aiopg-ctx
Jan 8, 2021
Merged

Fix AttributeError: __aexit__ for aiopg.connect and aiopg.create_pool#235
codeboten merged 12 commits intoopen-telemetry:masterfrom
srikanthccv:aiopg-ctx

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