Skip to content

Commit

Permalink
unconditionally delay all operations by 50ms
Browse files Browse the repository at this point in the history
other operations besides transfers can also be affected, this makes sure all are covered
  • Loading branch information
pschichtel committed Jan 9, 2024
1 parent a786dba commit 371c53b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions rasa_vier_cvg/cvg.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,8 @@ async def _perform_request(self, path: str, method: str, data: Optional[any]) ->

return status, body

def _perform_request_async(self, path: str, method: str, data: Optional[any], delay: float, process_result: Callable[[int, any], Coroutine[Any, Any, None]]):
def _perform_request_async(self, path: str, method: str, data: Optional[any], process_result: Callable[[int, any], Coroutine[Any, Any, None]]):
async def perform():
if delay > 0:
await asyncio.sleep(delay)
status, body = await self._perform_request(path, method, data)
await process_result(status, body)

Expand Down Expand Up @@ -185,7 +183,7 @@ async def do_nothing(*args):
pass
callback = do_nothing

self._perform_request_async(path, method="POST", data=new_body, delay=0.050, process_result=callback)
self._perform_request_async(path, method="POST", data=new_body, process_result=callback)

elif operation_name.startswith("dialog_"):
if operation_name == "dialog_delete":
Expand All @@ -204,6 +202,7 @@ async def send_custom_json(self, recipient_id: Text, json_message: Dict[Text, An
logger.info(f"Received custom json: {json_message} to {recipient_id}")
for operation_name, body in json_message.items():
if operation_name[:len(OPERATION_PREFIX)] == OPERATION_PREFIX:
await asyncio.sleep(0.050)
await self._execute_operation_by_name(operation_name[len(OPERATION_PREFIX):], body, recipient_id)

async def send_image_url(*args: Any, **kwargs: Any) -> None:
Expand Down

0 comments on commit 371c53b

Please sign in to comment.