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

awaited receiver is not awoken when messaged send into channel #54

Closed
GunnarMorrigan opened this issue Dec 14, 2022 · 6 comments
Closed

Comments

@GunnarMorrigan
Copy link

Hey guys,

I am writing an MQTT client that heavily uses channels for internal communication across Network <-> Handler <-> Client.
In some cases I saw that the client places a message into the channel to handler it is visible that there is a message if the length is checked but the Handler is not always awoken for the processing of the client request.

I Included an image here with some explanation.

image

This is a test function inside a library which runs on tokio multithreaded.

What could be causing the receiver not to awake?

Thanks in advance

@GunnarMorrigan GunnarMorrigan changed the title awaited receiver is not awoken when messaged send into in channel awaited receiver is not awoken when messaged send into channel Dec 14, 2022
@notgull
Copy link
Member

notgull commented Dec 14, 2022

Do you have a code example of this happening? You shouldn't be polling the receiver in a tight loop like this.

@GunnarMorrigan
Copy link
Author

Do you have a code example of this happening? You shouldn't be polling the receiver in a tight loop like this.

Well, I wasn't until I observed the behavior. Let me try and get a minimal reproduction of this.

@notgull
Copy link
Member

notgull commented Dec 14, 2022

Thanks! Also thanks for the diagram you made.

From a glance this seems to be either some kind of desync in ConcurrentQueue or the Event somehow dropping a notification, but I'd have to see the actual code to be sure.

@GunnarMorrigan
Copy link
Author

Thanks! Also thanks for the diagram you made.

From a glance this seems to be either some kind of desync in ConcurrentQueue or the Event somehow dropping a notification, but I'd have to see the actual code to be sure.

Thank you :)

Having some trouble getting a very minimal reproduction. Basically it works as expected in a very basic case.
I could give you access to the repo, if this would be oke with you?
It is a not yet published MQTT v5 client.

@GunnarMorrigan
Copy link
Author

Ok, closing the issue a multi_threaded test case can only run one task at a time?
One task was very busy making sure that the other task was not getting any (or very little) time to run. Sometimes the initial start would allow the other task to arrive at the waiting point at just the right moment to make it all work.

Thank you @notgull for your response and willingness to help. I really like smol and the crates around it :).

notgull added a commit that referenced this issue Sep 16, 2023
This commit makes async-channel use the new release of event-listener.
Highlights include a marked increase in efficiency and no_std support.

Supersedes #54

Signed-off-by: John Nunley <dev@notgull.net>
@NingLin-P
Copy link

Hi @notgull, is this really an issue of async-channl? I saw 51ab127 linked to this issue, is it fixed in v2.0.0? Asking because I'm debugging a problem and also suspect it is due to this issue.

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

No branches or pull requests

3 participants