Possible race condition while using cancellation from subscribe().with() #1445
manofthepeace
started this conversation in
General
Replies: 1 comment 2 replies
-
You might put the Note that the Hope it helps |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi Julien, sorry for the flood these days.
I am starting to play with the cancellation and I am not sure I fully understand how it works, or how it should work. Basically I am starting multiple "jobs" / pipelines, and I want to store their cancellations in a map, so a public api can cancel the jobs (if hell breaks lose). I also want to clean that map once the "job" is terminated.
If I do (simplified a lot..);
There is chances that the onTermination runs before the jobs.add. So the map will just get cruft long term.
I tried using the
UniSubscription
from the onSubscribe() something like this.But when doing it this way, it seems like the onTermination, or even onCancellation are never called. I wonder why? Is there a way to ensure I can a cancellable, before the subscription might happen, or even finish?
The way I found is quite dirty, and I would really appreciate a better way. Basically its something like this pseudo code-ish
Thanks.
Alex
Beta Was this translation helpful? Give feedback.
All reactions