Launch and detect the end of a subprocess


I’m working on a Django project and I’m trying to set up an idea that uses a technique I’ve never tried so I’m having some difficulties.

I have an application that can run a bash command to copy a folder to a directory.
It is a large folder and it takes about 20 minutes to copy, so I would like not to block the interface during this time.

I discovered that I can use the subprocess method of python to launch a command in the background. Which would be perfect, except now how do the user know when the subprocess is over?

All of my templates use a common template in which I have integrated a boostrap popup that appears a few seconds with the message and the desired color to indicate the success of a function for example.
I would like this popup to be used to indicate when this subprocess is finished, regardless of the page on which the user is at this time.

How can I set this up?
Has anyone ever done this kind of technique?

Thank you!

Do not try to do this from your Django process.

Use Celery or some other external-to-Django process manager for this.

Regarding your “asynchronous notification”, if you want this to be initiated by the server at any arbitrary point in time, you’d need to use a websocket in the browser and something like Channels on the server. This also implies either converting your application to an SPA-style structure or opening that websocket on every page.

thank you for your answer, I understand your recommendation.
I will find out about websockets.