Skip to content

Commit

Permalink
fix(client): fix the positional arguments error when using profile
Browse files Browse the repository at this point in the history
Raised error details:
`TypeError: do() takes 2 positional arguments but 3 were given`

PR Closed: #1150
  • Loading branch information
zhen.chen authored and linjiX committed Dec 6, 2021
1 parent de7349d commit 7db0527
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tensorbay/client/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ def _statistical(self, func: _Callable) -> _Callable:
"""

@wraps(func)
def wrapper(client: Client, method: str, url: str, **kwargs: Any) -> Response:
def wrapper(method: str, url: str, **kwargs: Any) -> Response:
path = urlparse(url).path
part = path.replace(_PATH_PREFIX, "") if path else url
key = f"[{method}] {part}"
data = kwargs.get("data")
file_size = self._get_file_size(data) if isinstance(data, MultipartEncoder) else 0
response = func(client, method, url, **kwargs)
response = func(method, url, **kwargs)
self._update(key, len(response.content), response.elapsed.total_seconds(), file_size)

return response
Expand Down Expand Up @@ -218,7 +218,7 @@ def start(self, multiprocess: bool = False) -> None:
self._summary = self._manager.dict()
else:
self._summary = {}
setattr(Client, "do", self._statistical(self.do_function))
setattr(Client, "do", staticmethod(self._statistical(self.do_function)))
setattr(RemoteFileMixin, "_urlopen", self._statistical_open(self.urlopen))

def stop(self) -> None:
Expand Down

0 comments on commit 7db0527

Please sign in to comment.