Closed jsaak closed 3 years ago
Yes, you can use Task#stop
.
Can you please add a function to the ruby specification? Task is an async class, and this belongs one level higher, I think.
You can use Fiber#raise
. Sorry, I didn't read your original issue clearly, and just assumed since it was on the async repo, that it was related to the async interfaces.
It would be great if you have time to try out Fiber#raise
to see if it meets your needs, and I think we should have extended testing in Async to ensure it's compatible.
Is there a way to unschedule a Fiber? Or stop it from inside? I have not found a way to do it. I try to use only the ruby 3 interface, to be portable.
I am writing an MQTT client and my program looks like this:
The program blocks in one of the recv_bytes() functions. If the TCP connection is broken, then i get back an empty string from recv(), and in that case I want to exit the second Fiber. If possible inside the recv_bytes() function so i do not have to check for disconnection every time I call it. I am looking something between exit and return. (I could throw an exception, but that is not very nice)
And also want to stop the sleeping Fiber, without killing the Reactor. Is this possible?