From ea83e4925d3e7d71f2360112f81d6c74bc34f40b Mon Sep 17 00:00:00 2001 From: nerudxlf Date: Wed, 25 Oct 2023 18:30:00 +0600 Subject: [PATCH] upd: handle user message --- rasa/core/channels/rest.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rasa/core/channels/rest.py b/rasa/core/channels/rest.py index 080e917ddedb..12e23287637f 100644 --- a/rasa/core/channels/rest.py +++ b/rasa/core/channels/rest.py @@ -35,7 +35,7 @@ def name(cls) -> Text: return "rest" def __init__(self): - self._background_task = set() + self._background_tasks = set() @staticmethod async def on_message_wrapper( @@ -130,7 +130,7 @@ def _logger_task_status(self, task): logger.error(f"{task.get_name()} Canceled Error!") except asyncio.InvalidStateError as e: logger.error(f"{task.get_name()} Invalid State Error!") - return self._background_task.discard + return self._background_tasks.discard def blueprint( self, on_new_message: Callable[[UserMessage], Awaitable[None]] @@ -180,9 +180,9 @@ async def receive(request: Request) -> Union[ResponseStream, HTTPResponse]: input_channel=input_channel, metadata=metadata, ) - task: asyncio.Task = asyncio.create_task(on_new_message(user_msg)) - self._background_tasks.add(task) - task.add_done_callback(self._logger_task_status(task)) + # using the example on line 109 + task = asyncio.ensure_future(on_new_message(user_msg)) + await task except CancelledError: structlogger.error( "rest.message.received.timeout", text=copy.deepcopy(text)