You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to write a script that continuously sends out messages every second that contain generated data. This module will only send out messages after the entire script has completed. For example, this fails as it waits continually:
import time
while True:
MycustomData = somefunc()
msg = {'payload': MycustomData}
node.send(msg)
time.sleep(1)
Is there a way to send messages continually? In my case, the somefunc() takes a long time to set up external hardware devices before it can retrieve data. It should be started only once to initialize everything then only queried for data when needed which would then send a new msg.
I think the way that code works now, I would have to run the setup of my instrumentation and all the overhead that comes with that every time I need a message sent. Is there a way to solve this?
Ideally, I should be able to send messages in a loop and have them sent out immediately when node.send() is called in which case, this node would never actually exit; it would just continually send messages.
The text was updated successfully, but these errors were encountered:
The code for this node has not been updated since several years
Myself, I tried something similar earlier with this node but I gave up and stopped struggeling. Instead I run all my Python scripts next to Node-RED and communicate with them via MQTT. I start the scripts with the exec node. Works perfect and you can leverage on all the power of Python like multi-threading etc
I need to write a script that continuously sends out messages every second that contain generated data. This module will only send out messages after the entire script has completed. For example, this fails as it waits continually:
Is there a way to send messages continually? In my case, the somefunc() takes a long time to set up external hardware devices before it can retrieve data. It should be started only once to initialize everything then only queried for data when needed which would then send a new msg.
I think the way that code works now, I would have to run the setup of my instrumentation and all the overhead that comes with that every time I need a message sent. Is there a way to solve this?
Ideally, I should be able to send messages in a loop and have them sent out immediately when node.send() is called in which case, this node would never actually exit; it would just continually send messages.
The text was updated successfully, but these errors were encountered: