Skip to content

Can not send multiple sequential messages #18

Open
@mecworks

Description

@mecworks

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions