Skip to content

Commit ebd1e38

Browse files
fix(aap): fixing asyncio error for asgi (#14700)
## Description Customer experienced error on stream endpoint on Daphne/Django application ## Testing This fix was tested on the repro application provided by the customer ## Additional Notes Importing asyncio globally may create bad interaction with gevent APPSEC-59237
1 parent ba014c0 commit ebd1e38

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

ddtrace/appsec/_handlers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import asyncio
21
import io
32
import json
43
from typing import Any
@@ -171,6 +170,9 @@ def _on_lambda_parse_body(
171170

172171
async def _on_asgi_request_parse_body(receive, headers):
173172
if asm_config._asm_enabled:
173+
# This must not be imported globally due to 3rd party patching timeline
174+
import asyncio
175+
174176
more_body = True
175177
body_parts = []
176178
try:
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
fixes:
3+
- |
4+
AAP: This fix resolves an issue where stream endpoints with daphne/django where unresponsive due to an asyncio error.

0 commit comments

Comments
 (0)