-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathasync_delay.json
More file actions
32 lines (32 loc) · 1.47 KB
/
async_delay.json
File metadata and controls
32 lines (32 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{
"node_id": "async_delay",
"name": "Async Delay",
"description": "Delays execution for a specified number of seconds.",
"category": "Utility",
"icon_path": "icons/timer.svg",
"inputs": [
{
"name": "exec_in",
"type": "exec"
},
{
"name": "input_data",
"type": "any"
},
{
"name": "seconds",
"type": "number"
}
],
"outputs": [
{
"name": "exec_out",
"type": "exec"
},
{
"name": "output_data",
"type": "any"
}
],
"python_code": "import asyncio\nfrom src.nodes.base import BaseNode\n\nclass AsyncDelayNode(BaseNode):\n name = \"Async Delay\"\n \n def __init__(self):\n super().__init__()\n self.icon_path = \"icons/timer.svg\"\n # [AUTO-GENERATED-PORTS-START]\n self.add_input(\"input_data\", \"any\")\n self.add_input(\"seconds\", \"number\")\n self.add_output(\"output_data\", \"any\")\n # [AUTO-GENERATED-PORTS-END]\n \n async def execute(self, inputs):\n data = inputs.get(\"input_data\")\n delay = float(inputs.get(\"seconds\", 1.0))\n \n # Demonstrates async non-blocking behavior\n await asyncio.sleep(delay)\n \n await self.set_output(\"exec_out\", True)\n return {\"output_data\": data}\n\ndef register_node():\n return AsyncDelayNode\n"
}