How to keep thread channels open?

What are ways of doing so? I tried loop and recv(); or recv.iter(), but is this the way of listening for incoming messages from a thread? I just need a thread to wait for messages.

Yes, that sounds like the way to go; either way should be fine.

“Tried” sounds like you might have had problems? Or did everything work as expected? So what where the problems, or why are you asking? What do you mean with “the way”?

Note on the wording: I would consider the channel “open” even at times while no-one is waiting for new messages, as long as receiver and sender handles still exist at all. Their drop implementations are what closes a channel. But I’m not certain whether that’s the technically correct terminology, or whether “open” has no precise (commonly agreed) meaning for channels at all.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.