From 7d8a6c407565907365bf73d3b72975816fc183c3 Mon Sep 17 00:00:00 2001 From: Blallo Date: Sat, 17 Aug 2019 22:22:14 -0300 Subject: [PATCH] Make push_to_loop public. --- bot_z/async_operator.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bot_z/async_operator.py b/bot_z/async_operator.py index 9259148..749d235 100644 --- a/bot_z/async_operator.py +++ b/bot_z/async_operator.py @@ -7,7 +7,7 @@ the Operator. """ import asyncio -from concurrent.futures import ThreadPoolExecutor +from concurrent.futures import ThreadPoolExecutor, Executor import functools import logging import typing as T @@ -19,9 +19,9 @@ from bot_z.exceptions import OperationFailed alog = logging.getLogger("asyncio") -async def _push_to_loop( +async def push_to_loop( loop: asyncio.AbstractEventLoop, - executor: ThreadPoolExecutor, + executor: Executor, func: T.Callable, *args, **kwargs @@ -52,7 +52,7 @@ class AsyncOperator(object): async def login(self, username: str, password: str) -> None: """Perform the login. Raise if failing.""" alog.debug("Logging in [%s]", self.name) - _ = await _push_to_loop( + _ = await push_to_loop( self.loop, self.executor, self.op.login, username, password ) if not self.op.logged_in: @@ -62,7 +62,7 @@ class AsyncOperator(object): async def logout(self) -> None: """Perform the logout. Raise if failing.""" alog.debug("Logging out [%s]", self.name) - _ = await _push_to_loop(self.loop, self.executor, self.op.logout) + _ = await push_to_loop(self.loop, self.executor, self.op.logout) if self.op.logged_in: raise OperationFailed("Failed to logout.") alog.info("Logged out [%s]", self.name) @@ -70,7 +70,7 @@ class AsyncOperator(object): async def checkin(self) -> None: """Perform the checkin. Raise if failing.""" alog.debug("Checking in [%s]", self.name) - _ = await _push_to_loop(self.loop, self.executor, self.op.check_in) + _ = await push_to_loop(self.loop, self.executor, self.op.check_in) if not self.op.checked_in: raise OperationFailed("Failed to checkin.") alog.info("Checked in [%s]", self.name) @@ -78,7 +78,7 @@ class AsyncOperator(object): async def checkout(self) -> None: """Perform the checkout. Raise if failing.""" alog.debug("Checking out [%s]", self.name) - _ = await _push_to_loop(self.loop, self.executor, self.op.check_out) + _ = await push_to_loop(self.loop, self.executor, self.op.check_out) if self.op.checked_in: raise OperationFailed("Failed to checkout.") alog.info("Checked out [%s]", self.name) @@ -89,7 +89,7 @@ class AsyncOperator(object): The list may be empty. """ alog.debug("Retrieving the list of movements [%s]", self.name) - res = await _push_to_loop(self.loop, self.executor, self.op.get_movements) + res = await push_to_loop(self.loop, self.executor, self.op.get_movements) alog.info("List of movements [%s]: %s", self.name, res) return res