fix(rnd): Make discord bot continuously running (#7792)
parent
183c72b2d0
commit
9084c31662
|
@ -78,6 +78,11 @@ class DiscordReaderBlock(Block):
|
|||
await client.start(token)
|
||||
|
||||
def run(self, input_data: "DiscordReaderBlock.Input") -> BlockOutput:
|
||||
while True:
|
||||
for output_name, output_value in self.__run(input_data):
|
||||
yield output_name, output_value
|
||||
|
||||
def __run(self, input_data: "DiscordReaderBlock.Input") -> BlockOutput:
|
||||
try:
|
||||
loop = asyncio.get_event_loop()
|
||||
future = self.run_bot(input_data.discord_bot_token.get_secret_value())
|
||||
|
|
|
@ -81,7 +81,7 @@ def execute_node(
|
|||
# Sanity check: validate the execution input.
|
||||
prefix = get_log_prefix(graph_exec_id, node_exec_id, node_block.name)
|
||||
exec_data, error = validate_exec(node, data.data, resolve_input=False)
|
||||
if not exec_data:
|
||||
if exec_data is None:
|
||||
logger.error(f"{prefix} Skip execution, input validation error: {error}")
|
||||
return
|
||||
|
||||
|
@ -93,7 +93,6 @@ def execute_node(
|
|||
for output_name, output_data in node_block.execute(exec_data):
|
||||
logger.warning(f"{prefix} Executed, output [{output_name}]:`{output_data}`")
|
||||
wait(upsert_execution_output(node_exec_id, output_name, output_data))
|
||||
update_execution(ExecutionStatus.COMPLETED)
|
||||
|
||||
for execution in _enqueue_next_nodes(
|
||||
api_client=api_client,
|
||||
|
@ -104,6 +103,9 @@ def execute_node(
|
|||
prefix=prefix,
|
||||
):
|
||||
yield execution
|
||||
|
||||
update_execution(ExecutionStatus.COMPLETED)
|
||||
|
||||
except Exception as e:
|
||||
error_msg = f"{e.__class__.__name__}: {e}"
|
||||
logger.exception(f"{prefix} failed with error. `%s`", error_msg)
|
||||
|
@ -437,7 +439,7 @@ class ExecutionManager(AppService):
|
|||
input_data = {}
|
||||
|
||||
input_data, error = validate_exec(node, input_data)
|
||||
if not input_data:
|
||||
if input_data is None:
|
||||
raise Exception(error)
|
||||
else:
|
||||
nodes_input.append((node.id, input_data))
|
||||
|
|
Loading…
Reference in New Issue