404background / node-red-contrib-python-venv

Node for python virtual environment
https://flows.nodered.org/node/@background404/node-red-contrib-python-venv
MIT License
10 stars 4 forks source link

Fpm/error handling #23

Closed FrederikPM closed 4 months ago

FrederikPM commented 4 months ago

Test flow:

[    {        "id": "25441caf3c8534e2",        "type": "venv",        "z": "7a7ae303f662be9f",        "venvconfig": "4657b6fbdbaf6f7e",        "name": "venv test",        "code": "# Import the time library\nimport time\nstart = time.time()\n\noffset = msg[\"payload\"] if \"payload\" in msg else 0\n\ntime.sleep(1)\nend = time.time()\nlength = end - start\nprint(f'Time: {length}')\n\nwhile True:\n    time.sleep(1)\n    end = time.time()\n    length = end - start\n    if length > 2:\n        raise Exception(\"EXCEPTION!\") \n    print(f'Time: {length + offset}')",        "continuous": true,        "stdInData": false,        "x": 380,        "y": 180,        "wires": [            [                "114b918e3eb7ad96"            ]        ]    },    {        "id": "446c4d54c3afdb80",        "type": "inject",        "z": "7a7ae303f662be9f",        "name": "",        "props": [            {                "p": "payload"            }        ],        "repeat": "",        "crontab": "",        "once": false,        "onceDelay": 0.1,        "topic": "",        "payload": "5",        "payloadType": "num",        "x": 110,        "y": 220,        "wires": [            [                "25441caf3c8534e2"            ]        ]    },    {        "id": "5056f4320a8479d0",        "type": "inject",        "z": "7a7ae303f662be9f",        "name": "terminate",        "props": [            {                "p": "terminate",                "v": "true",                "vt": "bool"            }        ],        "repeat": "",        "crontab": "",        "once": false,        "onceDelay": 0.1,        "topic": "",        "x": 120,        "y": 140,        "wires": [            [                "25441caf3c8534e2"            ]        ]    },    {        "id": "114b918e3eb7ad96",        "type": "debug",        "z": "7a7ae303f662be9f",        "name": "debug 1",        "active": true,        "tosidebar": true,        "console": false,        "tostatus": false,        "complete": "payload",        "targetType": "msg",        "statusVal": "",        "statusType": "auto",        "x": 640,        "y": 180,        "wires": []    },    {        "id": "89aac1fd133f1b5b",        "type": "catch",        "z": "7a7ae303f662be9f",        "name": "",        "scope": null,        "uncaught": false,        "x": 540,        "y": 300,        "wires": [            [                "73882114753d4bc1"            ]        ]    },    {        "id": "73882114753d4bc1",        "type": "debug",        "z": "7a7ae303f662be9f",        "name": "debug 98",        "active": true,        "tosidebar": true,        "console": false,        "tostatus": false,        "complete": "true",        "targetType": "full",        "statusVal": "",        "statusType": "auto",        "x": 740,        "y": 280,        "wires": []    },    {        "id": "4657b6fbdbaf6f7e",        "type": "venv-config",        "venvname": "pyenv",        "version": "default"    }]
404background commented 4 months ago

Thank you @FrederikPM !

I tested the flow. Before the change, the program could not catch errors at the error node. スクリーンショット 2024-07-11 111834

After the change, the error could be caught at the error node. スクリーンショット 2024-07-11 110748

It worked fine, so I merge this Pull Request.