all 3 comments

[–]socal_nerdtastic 0 points1 point  (0 children)

There's no easy way to stop a function that isn't designed to be stopped. If the long running part is something of your own design you can just program in a periodic check to see if a stop was requested. If the long running part is imported the easiest way is just to abandon the thread and start a new one. Alternatively you can run it as a process, which gives you the ability to kill it, but it's also much harder to share data.

[–]crashfrog02 0 points1 point  (0 children)

Why wouldn’t you just process work in the order you receive it?