Pārlūkot izejas kodu

replace async by normal

highing666 3 gadi atpakaļ
vecāks
revīzija
34f040e5ca
2 mainītis faili ar 9 papildinājumiem un 4 dzēšanām
  1. 2 2
      app/controllers/targets/temperature.py
  2. 7 2
      app/services/transfer.py

+ 2 - 2
app/controllers/targets/temperature.py

@@ -379,11 +379,11 @@ class TargetDeliver:
             if controlled_result["need_switch_off"]:
                 await transfer.set_temporary_custom()
             if controlled_result["new_temporary_target"]:
-                await transfer.set_custom_target(
+                transfer.set_custom_target(
                     "temperature", controlled_result["new_temporary_target"], "0"
                 )
             if controlled_result["new_global_target"]:
-                await transfer.set_custom_target(
+                transfer.set_custom_target(
                     "temperature", controlled_result["new_global_target"], "1"
                 )
             if (

+ 7 - 2
app/services/transfer.py

@@ -1,9 +1,11 @@
 # -*- coding: utf-8 -*-
 
 from enum import Enum
+import time
 from typing import Dict, List
 
 import arrow
+import httpx
 import numpy as np
 import pandas as pd
 from httpx import AsyncClient, URL
@@ -178,7 +180,7 @@ class SpaceInfoService(Service):
 
         return result
 
-    async def set_custom_target(
+    def set_custom_target(
         self, form: str, target_value: Dict[str, List[float]], flag: str = "1"
     ) -> None:
         url = self._base_url.join("duoduo-service/transfer/environment/target/setting")
@@ -189,7 +191,10 @@ class SpaceInfoService(Service):
             "type": form,
             "flag": flag,
         }
-        await self._post(url, params=params, payload=target_value)
+        start = time.perf_counter()
+        httpx.post(url, params=params, json=target_value)
+        logger.debug(time.perf_counter() - start)
+        # await self._post(url, params=params, payload=target_value)
 
     async def set_temporary_custom(self) -> None:
         url = self._base_url.join("duoduo-service/transfer/environment/setServiceFlag")