Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not send multiple sequential messages #18

Open
mecworks opened this issue May 3, 2023 · 2 comments
Open

Can not send multiple sequential messages #18

mecworks opened this issue May 3, 2023 · 2 comments

Comments

@mecworks
Copy link

mecworks commented May 3, 2023

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.

@krambriw
Copy link

krambriw commented May 3, 2023

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

@mecworks
Copy link
Author

mecworks commented May 4, 2023

The exec node will allow sending multiple messages while it's running. This node needs to be updated to support the same type of functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants