Skip to content

Commit 7d3183f

Browse files
committed
fix: replace deprecated asyncio.coroutine with async/await in aiohttp backend
asyncio.coroutine was removed in Python 3.11. Convert to native async/await syntax which has been supported since Python 3.5.
1 parent 0ba7f59 commit 7d3183f

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

pusher/aiohttp.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
division)
88

99
import aiohttp
10-
import asyncio
1110

1211
from pusher.http import process_response
1312

@@ -21,23 +20,22 @@ def __init__(self, client):
2120
self.client = client
2221

2322

24-
@asyncio.coroutine
25-
def send_request(self, request):
23+
async def send_request(self, request):
2624
session = response = None
2725
try:
2826
session = aiohttp.ClientSession()
29-
response = yield from session.request(
27+
response = await session.request(
3028
request.method,
3129
"%s%s" % (request.base_url, request.path),
3230
params=request.query_params,
3331
data=request.body,
3432
headers=request.headers,
3533
timeout=self.client.timeout
3634
)
37-
body = yield from response.text('utf-8')
35+
body = await response.text('utf-8')
3836
return process_response(response.status, body)
3937
finally:
4038
if response is not None:
4139
response.close()
4240
if session is not None:
43-
yield from session.close()
41+
await session.close()

0 commit comments

Comments
 (0)