How to terminate long computation in a callback function

Dear all,

I am a new one for using Dash. I am trying to run a long computation in a callback function. Is any solution can terminate a long process before finishing?

Use case:

  1. user clicks button to run a long process in a callback function.
  2. before finished, user thinks the computation is too long so as to terminate it by another button.

Can this use case implement it? thank you. :smiley:

Best regards,

@Ricky66 - Lucky timing! We’re actually working on a prototype for this functionality in “dash-labs” (our package for prototypes and prereleases). See 📣 Dash Labs 0.3.0: @app.long_callback support - #6 by skiefer and give it a try!

1 Like

Hello @chriddyp,

Thanks for the information quickly. I will give it try.
If I have a use case problem, could I still query you?

Best regards,

Hi @chriddyp,

I followed :mega: Dash Labs 0.3.0: @app.long_callback support - #6 by skiefer this instruction to try their example code.

I met this problem:


image
image

my package environment as below:

Do you have the same problem as me?

Thanks and best regards,

Ricky H Chen

Hi Ricky!, Thanks for giving this a spin. Based on the screen shot of that error message, do I gather correctly that you’re running this on Windows? If so, I think this may be an issue with the difference between how multiprocessing is handled on Windows compared to MacOS/Linux.

I’ll try to take a look soon. Thanks!
-Jon

1 Like

Hi @jmmease,

Thanks for your valuable information, I don’t know the multiprocessing mechanisms are different in different OS actually.

For answering your question:
“do I gather correctly that you’re running this on Windows?” => Yes, I ran the example code on Windows 10.

Thanks and best regards :slightly_smiling_face:,

Ricky H Chen

Windows support is now available in version 0.4.0. See 📣 Dash Labs 0.4.0: @long_callback caching and Windows support.

2 Likes

Hi @jmmease,

Thanks a lot for your development. :slightly_smiling_face:
I will give it a try, and feedback to you.

Thanks and best regards,
Ricky H Chen

1 Like