Killing an exec node

I have used many times a change node setting a "msg.kill" to the value of "kill -2" to stop an exec node running a python script (python -u /../..something.py).

But I just experienced that, for some reason I don't understand, this may not work all the times.
I have tried using an exact copy of the flow with the same exec running the same script. The one on the top stops with the msg.kill as above.
The one at the bottom doesn't. Even if I disconnect the wires and deploy, it doesn't stop. I have to stop it from terminal using the pid.

I am not sure about what is going on!
Any hint?
Thanks

[
    {
        "id": "a10ded18eb7571d8",
        "type": "inject",
        "z": "faef46163bd149ff",
        "name": "Start",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "10101",
        "payloadType": "num",
        "x": 850,
        "y": 360,
        "wires": [
            [
                "2f2ae80f72d3f3db"
            ]
        ]
    },
    {
        "id": "2f2ae80f72d3f3db",
        "type": "exec",
        "z": "faef46163bd149ff",
        "command": "python -u /home/bms/Dev/APItest/APItest.py",
        "addpay": "",
        "append": "",
        "useSpawn": "true",
        "timer": "",
        "winHide": false,
        "oldrc": false,
        "name": "Exec",
        "x": 1130,
        "y": 360,
        "wires": [
            [],
            [],
            []
        ]
    },
    {
        "id": "11967cc303a2c401",
        "type": "inject",
        "z": "faef46163bd149ff",
        "name": "Stop",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 850,
        "y": 400,
        "wires": [
            [
                "5f3e9c4c97e16aaf"
            ]
        ]
    },
    {
        "id": "5f3e9c4c97e16aaf",
        "type": "change",
        "z": "faef46163bd149ff",
        "name": "Kill",
        "rules": [
            {
                "t": "set",
                "p": "kill",
                "pt": "msg",
                "to": "Kill -2",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 970,
        "y": 400,
        "wires": [
            [
                "2f2ae80f72d3f3db"
            ]
        ]
    },
    {
        "id": "94b24c088a74dd06",
        "type": "inject",
        "z": "faef46163bd149ff",
        "name": "Start",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "x": 850,
        "y": 480,
        "wires": [
            [
                "130ea29504cc69f4"
            ]
        ]
    },
    {
        "id": "130ea29504cc69f4",
        "type": "exec",
        "z": "faef46163bd149ff",
        "command": "python -u /home/bms/Dev/APItest/APItest.py",
        "addpay": "",
        "append": "",
        "useSpawn": "true",
        "timer": "",
        "winHide": false,
        "oldrc": false,
        "name": "Exec",
        "x": 1130,
        "y": 480,
        "wires": [
            [],
            [],
            []
        ]
    },
    {
        "id": "7ee6296a0187bd67",
        "type": "inject",
        "z": "faef46163bd149ff",
        "name": "Stop",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 850,
        "y": 540,
        "wires": [
            [
                "5cd4fb73d7364806"
            ]
        ]
    },
    {
        "id": "5cd4fb73d7364806",
        "type": "change",
        "z": "faef46163bd149ff",
        "name": "Kill",
        "rules": [
            {
                "t": "set",
                "p": "kill",
                "pt": "msg",
                "to": "kill -2",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 990,
        "y": 540,
        "wires": [
            [
                "130ea29504cc69f4"
            ]
        ]
    }
]

Check to make sure that you aren't creating a 2nd shell or your command is spawning another executable. In those cases, the "inner" executable may have a different PID which, depending on how it runs, might not be killed when you terminate the outer.

I did check and made a copy of the script being executed (script 1 , script 2) so the two exec nodes do not run the same script. Also, the exec nodes are set in exec mode. The problem is still the same. I can stop one of them but not the other.
The code inside the script is nothing:

import time

while True:
    print("Running...")
    time.sleep(1)

I don't understand if this is a problem on my system or something else.

Odd, can't think of anything.

I have replicated the same flow with the same files on a different device (Nuc).
The problem doesn't happen there.

I am a bit lost now. I don't know how to solve the issue on the Pi.

If any hint..... will be appreciated.
Thanks

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.