Skip to content

Commit 77918e8

Browse files
authored
deprecate loop parameter (Azure#19927)
* deprecate loop parameter * update
1 parent 360a418 commit 77918e8

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

sdk/core/azure-core/azure/core/pipeline/transport/_aiohttp.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
# IN THE SOFTWARE.
2424
#
2525
# --------------------------------------------------------------------------
26+
import sys
2627
from typing import Any, Optional, AsyncIterator as AsyncIteratorType
2728
from collections.abc import AsyncIterator
2829
try:
@@ -58,7 +59,6 @@ class AioHttpTransport(AsyncHttpTransport):
5859
Fully asynchronous implementation using the aiohttp library.
5960
6061
:param session: The client session.
61-
:param loop: The event loop.
6262
:param bool session_owner: Session owner. Defaults True.
6363
6464
:keyword bool use_env_settings: Uses proxy settings from environment. Defaults to True.
@@ -73,6 +73,8 @@ class AioHttpTransport(AsyncHttpTransport):
7373
:caption: Asynchronous transport with aiohttp.
7474
"""
7575
def __init__(self, *, session: Optional[aiohttp.ClientSession] = None, loop=None, session_owner=True, **kwargs):
76+
if loop and sys.version_info >= (3, 10):
77+
raise ValueError("Starting with Python 3.10, asyncio doesn’t support loop as a parameter anymore")
7678
self._loop = loop
7779
self._session_owner = session_owner
7880
self.session = session

sdk/core/azure-core/tests/test_basic_transport.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,3 +1138,11 @@ def test_conflict_timeout(caplog):
11381138
with pytest.raises(ValueError):
11391139
with Pipeline(transport) as pipeline:
11401140
pipeline.run(request, connection_timeout=(100, 100), read_timeout = 100)
1141+
1142+
@pytest.mark.skipif(sys.version_info < (3, 10), reason="Loop parameter is deprecated since Python 3.10")
1143+
def test_aiohttp_loop():
1144+
import asyncio
1145+
from azure.core.pipeline.transport import AioHttpTransport
1146+
loop = asyncio._get_running_loop()
1147+
with pytest.raises(ValueError):
1148+
transport = AioHttpTransport(loop=loop)

0 commit comments

Comments
 (0)