How to put and use an interrupt button?

I developed a Monte-Carlos simulation as follows.

When the number of simulation is large and it takes forever, I want to interrupt the execution. How could I do that? The following simple exit() commend did not work…

def stop_button_click(self, **event_args):
exit(‘You stopped the app.’)

Thank you!

Hi @hyoungkang and welcome to the forum,

It’d be good to see a clone link so others can dig into your code (you’ve shared a link to the live app).

One idea:

Try moving your heavy tasks to the server as a background task and check the progress on the client. You could also signal the progress of the task on the client with a custom component.

Anvil Docs | Communicating with Background Tasks

1 Like

Thank you for the reply. Now, I have the following error message: “UplinkDisconnectedError: The uplink server for “function_name” has been disconnected” Does this message happen because I am still testing a free plan with my colleagues?

If you really stopped the app, then it is no longer running, hence no longer able to respond to requests from the Anvil Server. It is “disconnected”.