-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(aiomysql): fix AttributeError: __aenter__ when using cursor as a …
…context manager (#3879) (#3886) The implementation of Connection.cursor is a sync function that returns a context manager around a coroutine. Our integration changed the def cursor() function into an async def cursor(): function. This causes issues when using async with conn.cursor(): as the result of our wrapped function would be a coroutine and not an async friendly context manager. (cherry picked from commit 2066030) Co-authored-by: Brett Langdon <brett.langdon@datadoghq.com>
- Loading branch information
1 parent
d10539f
commit d7fe83b
Showing
3 changed files
with
69 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
releasenotes/notes/fix-aiomysql-async-with-usage-ac6510f48ed0e6fe.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
fixes: | ||
- | | ||
aiomysql: fix ``AttributeError: __aenter__`` when using cursors as context managers. |
30 changes: 30 additions & 0 deletions
30
tests/snapshots/tests.contrib.aiomysql.test_aiomysql.test_async_with_usage.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[[ | ||
{ | ||
"name": "mysql.query", | ||
"service": null, | ||
"resource": "SELECT 1", | ||
"trace_id": 0, | ||
"span_id": 1, | ||
"parent_id": 0, | ||
"type": "sql", | ||
"meta": { | ||
"db.name": "test", | ||
"db.user": "test", | ||
"out.host": "127.0.0.1", | ||
"runtime-id": "f09816a4d96c4c51abaf8769c10b0a7a", | ||
"sql.query": "SELECT 1" | ||
}, | ||
"metrics": { | ||
"_dd.agent_psr": 1.0, | ||
"_dd.measured": 1, | ||
"_dd.top_level": 1, | ||
"_dd.tracer_kr": 1.0, | ||
"_sampling_priority_v1": 1, | ||
"db.rowcount": 1, | ||
"db.rownumber": 0, | ||
"out.port": 3306, | ||
"system.pid": 89502 | ||
}, | ||
"duration": 1370000, | ||
"start": 1656453688953207000 | ||
}]] |