@@ -67,6 +67,7 @@ class CVGOutput(OutputChannel):
67
67
on_message : Callable [[UserMessage ], Awaitable [Any ]]
68
68
base_url : str
69
69
proxy : Optional [str ]
70
+ task_container : TaskContainer
70
71
71
72
@classmethod
72
73
def name (cls ) -> Text :
@@ -92,25 +93,25 @@ def _is_ignored(self, custom_json) -> bool:
92
93
93
94
async def _perform_request_sync (self , path : str , method : str , data : Optional [any ], dialog_id : Optional [str ], retries : int = 0 ) -> (Optional [int ], any ):
94
95
url = f"{ self .base_url } { path } "
96
+ status = - 1
97
+ body = None
95
98
try :
96
99
async with aiohttp .request (method , url , json = data , proxy = self .proxy ) as res :
97
100
status = res .status
98
101
if status == 204 :
99
102
return status , {}
100
103
101
104
body = await res .json ()
102
- if status < 200 or status >= 300 :
103
- logger .error (f"{ dialog_id } - Failed to send text message to CVG via { url } : status={ status } , body={ body } " )
104
-
105
105
return status , body
106
106
except aiohttp .ClientResponseError as e :
107
- logger . error ( f" { dialog_id } - Failed to send text message to CVG via { url } : status= { e .status } , message= { e .message } " )
107
+ return e .status , e .message
108
108
except aiohttp .ClientConnectionError :
109
109
if retries < 3 :
110
110
logger .error (f"{ dialog_id } - The connection failed, retrying..." )
111
- await self ._perform_request_sync (path , method , data , dialog_id , retries + 1 )
111
+ return await self ._perform_request_sync (path , method , data , dialog_id , retries + 1 )
112
112
else :
113
113
logger .error (f"{ dialog_id } - { retries } retries all failed, that's it!" )
114
+ return status , body
114
115
115
116
def _perform_request_async (self , path : str , method : str , data : Optional [any ], dialog_id : Optional [str ], process_result : Callable [[int , any ], Coroutine [Any , Any , None ]]):
116
117
async def perform ():
@@ -122,7 +123,8 @@ async def perform():
122
123
async def _perform_request (self , path : str , method : str , data : Optional [any ], dialog_id : Optional [str ]):
123
124
async def handle_result (status_code , response_body ):
124
125
if not 200 <= status_code < 300 :
125
- logger .info (f"{ dialog_id } - { method } request to { path } failed: { status_code } with body { response_body } " )
126
+ url = f"{ self .base_url } { path } "
127
+ logger .error (f"{ dialog_id } - Failed to send command to CVG via { method } { url } : status={ status_code } , message={ response_body } " )
126
128
return
127
129
128
130
if self .blocking_output :
0 commit comments