Skip to content

Commit

Permalink
[Storage] Remove loop from file share (#25440)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincenttran-msft committed Aug 11, 2022
1 parent 2d7e636 commit 3ef21f0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
# --------------------------------------------------------------------------
# pylint: disable=invalid-overridden-method
import functools
import sys
import time
import warnings
from typing import ( # pylint: disable=unused-import
Optional, Union, Any, Dict, TYPE_CHECKING
)
Expand Down Expand Up @@ -70,8 +72,6 @@ class ShareDirectoryClient(AsyncStorageAccountHostsMixin, ShareDirectoryClientBa
:keyword str secondary_hostname:
The hostname of the secondary endpoint.
:keyword loop:
The event loop to run the asynchronous tasks.
:keyword int max_range_size: The maximum range size used for a file upload. Defaults to 4*1024*1024.
"""
def __init__( # type: ignore
Expand All @@ -85,17 +85,18 @@ def __init__( # type: ignore
# type: (...) -> None
kwargs['retry_policy'] = kwargs.get('retry_policy') or ExponentialRetry(**kwargs)
loop = kwargs.pop('loop', None)
if loop and sys.version_info >= (3, 8):
warnings.warn("The 'loop' parameter was deprecated from asyncio's high-level"
"APIs in Python 3.8 and is no longer supported.", DeprecationWarning)
super(ShareDirectoryClient, self).__init__(
account_url,
share_name=share_name,
directory_path=directory_path,
snapshot=snapshot,
credential=credential,
loop=loop,
**kwargs)
self._client = AzureFileStorage(self.url, base_url=self.url, pipeline=self._pipeline, loop=loop)
self._client = AzureFileStorage(self.url, base_url=self.url, pipeline=self._pipeline)
self._client._config.version = get_api_version(kwargs) # pylint: disable=protected-access
self._loop = loop

def get_file_client(self, file_name, **kwargs):
# type: (str, Any) -> ShareFileClient
Expand All @@ -118,7 +119,7 @@ def get_file_client(self, file_name, **kwargs):
return ShareFileClient(
self.url, file_path=file_name, share_name=self.share_name, snapshot=self.snapshot,
credential=self.credential, api_version=self.api_version, _hosts=self._hosts, _configuration=self._config,
_pipeline=_pipeline, _location_mode=self._location_mode, loop=self._loop, **kwargs)
_pipeline=_pipeline, _location_mode=self._location_mode, **kwargs)

def get_subdirectory_client(self, directory_name, **kwargs):
# type: (str, Any) -> ShareDirectoryClient
Expand Down Expand Up @@ -149,7 +150,7 @@ def get_subdirectory_client(self, directory_name, **kwargs):
return ShareDirectoryClient(
self.url, share_name=self.share_name, directory_path=directory_path, snapshot=self.snapshot,
credential=self.credential, api_version=self.api_version, _hosts=self._hosts, _configuration=self._config,
_pipeline=_pipeline, _location_mode=self._location_mode, loop=self._loop, **kwargs)
_pipeline=_pipeline, _location_mode=self._location_mode, **kwargs)

@distributed_trace_async
async def create_directory(self, **kwargs):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
# --------------------------------------------------------------------------
# pylint: disable=too-many-lines, invalid-overridden-method, too-many-public-methods
import functools
import sys
import time
import warnings
from io import BytesIO
from typing import Optional, Union, IO, List, Tuple, Dict, Any, Iterable, TYPE_CHECKING # pylint: disable=unused-import

Expand Down Expand Up @@ -127,8 +129,6 @@ class ShareFileClient(AsyncStorageAccountHostsMixin, ShareFileClientBase):
:keyword str secondary_hostname:
The hostname of the secondary endpoint.
:keyword loop:
The event loop to run the asynchronous tasks.
:keyword int max_range_size: The maximum range size used for a file upload. Defaults to 4*1024*1024.
"""

Expand All @@ -144,13 +144,15 @@ def __init__( # type: ignore
# type: (...) -> None
kwargs["retry_policy"] = kwargs.get("retry_policy") or ExponentialRetry(**kwargs)
loop = kwargs.pop('loop', None)
if loop and sys.version_info >= (3, 8):
warnings.warn("The 'loop' parameter was deprecated from asyncio's high-level"
"APIs in Python 3.8 and is no longer supported.", DeprecationWarning)
super(ShareFileClient, self).__init__(
account_url, share_name=share_name, file_path=file_path, snapshot=snapshot,
credential=credential, loop=loop, **kwargs
credential=credential, **kwargs
)
self._client = AzureFileStorage(self.url, base_url=self.url, pipeline=self._pipeline, loop=loop)
self._client = AzureFileStorage(self.url, base_url=self.url, pipeline=self._pipeline)
self._client._config.version = get_api_version(kwargs) # pylint: disable=protected-access
self._loop = loop

@distributed_trace_async
async def acquire_lease(self, lease_id=None, **kwargs):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# license information.
# --------------------------------------------------------------------------
# pylint: disable=invalid-overridden-method
import warnings
import sys
from typing import ( # pylint: disable=unused-import
Optional, Union, Dict, Any, Iterable, TYPE_CHECKING
)
Expand Down Expand Up @@ -67,8 +69,6 @@ class ShareClient(AsyncStorageAccountHostsMixin, ShareClientBase):
:keyword str secondary_hostname:
The hostname of the secondary endpoint.
:keyword loop:
The event loop to run the asynchronous tasks.
:keyword int max_range_size: The maximum range size used for a file upload. Defaults to 4*1024*1024.
"""
def __init__( # type: ignore
Expand All @@ -81,16 +81,17 @@ def __init__( # type: ignore
# type: (...) -> None
kwargs['retry_policy'] = kwargs.get('retry_policy') or ExponentialRetry(**kwargs)
loop = kwargs.pop('loop', None)
if loop and sys.version_info >= (3, 8):
warnings.warn("The 'loop' parameter was deprecated from asyncio's high-level"
"APIs in Python 3.8 and is no longer supported.", DeprecationWarning)
super(ShareClient, self).__init__(
account_url,
share_name=share_name,
snapshot=snapshot,
credential=credential,
loop=loop,
**kwargs)
self._client = AzureFileStorage(self.url, base_url=self.url, pipeline=self._pipeline, loop=loop)
self._client = AzureFileStorage(self.url, base_url=self.url, pipeline=self._pipeline)
self._client._config.version = get_api_version(kwargs) # pylint: disable=protected-access
self._loop = loop

def get_directory_client(self, directory_path=None):
# type: (Optional[str]) -> ShareDirectoryClient
Expand All @@ -110,7 +111,7 @@ def get_directory_client(self, directory_path=None):
return ShareDirectoryClient(
self.url, share_name=self.share_name, directory_path=directory_path or "", snapshot=self.snapshot,
credential=self.credential, api_version=self.api_version, _hosts=self._hosts, _configuration=self._config,
_pipeline=_pipeline, _location_mode=self._location_mode, loop=self._loop)
_pipeline=_pipeline, _location_mode=self._location_mode)

def get_file_client(self, file_path):
# type: (str) -> ShareFileClient
Expand All @@ -130,7 +131,7 @@ def get_file_client(self, file_path):
return ShareFileClient(
self.url, share_name=self.share_name, file_path=file_path, snapshot=self.snapshot,
credential=self.credential, api_version=self.api_version, _hosts=self._hosts, _configuration=self._config,
_pipeline=_pipeline, _location_mode=self._location_mode, loop=self._loop)
_pipeline=_pipeline, _location_mode=self._location_mode)

@distributed_trace_async()
async def acquire_lease(self, **kwargs):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# --------------------------------------------------------------------------
# pylint: disable=invalid-overridden-method
import functools
import sys
import warnings
from typing import ( # pylint: disable=unused-import
Union, Optional, Any, Iterable, Dict, List,
TYPE_CHECKING
Expand Down Expand Up @@ -67,8 +69,6 @@ class ShareServiceClient(AsyncStorageAccountHostsMixin, ShareServiceClientBase):
:keyword str secondary_hostname:
The hostname of the secondary endpoint.
:keyword loop:
The event loop to run the asynchronous tasks.
:keyword int max_range_size: The maximum range size used for a file upload. Defaults to 4*1024*1024.
.. admonition:: Example:
Expand All @@ -88,14 +88,15 @@ def __init__(
# type: (...) -> None
kwargs['retry_policy'] = kwargs.get('retry_policy') or ExponentialRetry(**kwargs)
loop = kwargs.pop('loop', None)
if loop and sys.version_info >= (3, 8):
warnings.warn("The 'loop' parameter was deprecated from asyncio's high-level"
"APIs in Python 3.8 and is no longer supported.", DeprecationWarning)
super(ShareServiceClient, self).__init__(
account_url,
credential=credential,
loop=loop,
**kwargs)
self._client = AzureFileStorage(self.url, base_url=self.url, pipeline=self._pipeline, loop=loop)
self._client = AzureFileStorage(self.url, base_url=self.url, pipeline=self._pipeline)
self._client._config.version = get_api_version(kwargs) # pylint: disable=protected-access
self._loop = loop

@distributed_trace_async
async def get_service_properties(self, **kwargs):
Expand Down Expand Up @@ -370,4 +371,4 @@ def get_share_client(self, share, snapshot=None):
return ShareClient(
self.url, share_name=share_name, snapshot=snapshot, credential=self.credential,
api_version=self.api_version, _hosts=self._hosts, _configuration=self._config,
_pipeline=_pipeline, _location_mode=self._location_mode, loop=self._loop)
_pipeline=_pipeline, _location_mode=self._location_mode)

0 comments on commit 3ef21f0

Please sign in to comment.