Skip to content

[help request] How to wrap publishAsync in a Future #252

@aefn

Description

@aefn

Dear Experts,
I have a scenario like this:
1 . connect
2 . publish 10 packet asynchronously
3. disconnect

the signature of publishAsync is publishAsync(topic, payload, QoS, ackCallback=None) link

how can I wrap this function to a async function?
I want to have something like this:

async def publish:
    publishAsync(arg,cb)  # I don't know how should I wait for this, using await does not work
pass


tasks = [publish for i in range(10)]
connect()
loop.run(tasks) # run all in parallel and wait until get their pubAck
disconnect()

I appreciate in advance
ps : I know that maybe it can be implemented in SDK2 but I need to use SDK1

Metadata

Metadata

Assignees

Labels

guidanceQuestion that needs advice or information.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions