From 98e26ece504d77023bc270448b0e1da443c83d76 Mon Sep 17 00:00:00 2001 From: Evgeny Smyshlyaev Date: Thu, 14 Mar 2019 14:15:29 +0300 Subject: [PATCH] Revert "Futures for detect and recieve #264 (#433)" (#464) --- analytics/analytics/analytic_unit_worker.py | 25 ++------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/analytics/analytics/analytic_unit_worker.py b/analytics/analytics/analytic_unit_worker.py index 3ede390..02f7cff 100644 --- a/analytics/analytics/analytic_unit_worker.py +++ b/analytics/analytics/analytic_unit_worker.py @@ -17,8 +17,6 @@ class AnalyticUnitWorker: self._detector = detector self._executor: Executor = executor self._training_feature: asyncio.Future = None - self._detection_feature: asyncio.Future = None - self._recieve_feature: asyncio.Future = None async def do_train( self, payload: Union[list, dict], data: pd.DataFrame, cache: Optional[ModelCache] @@ -33,30 +31,11 @@ class AnalyticUnitWorker: return cache async def do_detect(self, data: pd.DataFrame, cache: Optional[ModelCache]) -> dict: - self._detection_feature = asyncio.get_event_loop().run_in_executor( - self._executor, self._detector.detect, data, cache - ) - try: - detect_results = await self._detection_feature - return detect_results - except CancelledError as e: - return {} - + return self._detector.detect(data, cache) def cancel(self): if self._training_feature is not None: self._training_feature.cancel() - if self._detection_feature is not None: - self._detection_feature.cancel() - if self._recieve_feature is not None: - self._recieve_feature.cancel() async def recieve_data(self, data: pd.DataFrame, cache: Optional[ModelCache]): - self._recieve_feature = asyncio.get_event_loop().run_in_executor( - self._executor, self._detector.recieve_data, data, cache - ) - try: - detect_results = await self._recieve_feature - return detect_results - except CancelledError as e: - return None + return self._detector.recieve_data(data, cache)