Skip to content
Discussion options

You must be logged in to vote

All async_mqtt member funcitons that start with async_ dispatch the request to the corresponding executor.
See https://redboltz.github.io/async_mqtt/doc/latest/async_mqtt/functionality/thread_safe.html

However, even if the async_mqtt do that, coroutine mechanism override it by coroutine's executor.
So the code example you post is thread unsafe.
amcl1.async_publish() is called from main() function. Even if amcl1 is running on ioc1.executor() and async_mqtt post the request to it, main()'s implicit executor is used. It is coroutine's limitation.

In order to solve the issue, you can use co_spawn for publish processing.
And it is the correct way to pub/sub simultaneously.
Instead of calling a…

Replies: 7 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by chipsik-afk
Comment options

You must be logged in to vote
1 reply
@redboltz
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@redboltz
Comment options

Comment options

You must be logged in to vote
1 reply
@chipsik-afk
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants