Is it possible to stop the execution of a script temporarily on macOS? I have a Python script that learns a Deep Learning model. It takes so much time to execute (usually more than 6 hours).

Now, the problem is it is MacBook Pro and I frequently go out with it, and sometimes cafes lack outlets. In such cases the Mac is going to run out just in 90 minutes even from 100% battery, as the Python program uses all the resources available.

I would rather like to stop or at least restrict the program while I'm on cafes without charging the laptop, and later make it start learning again. Is this possible in macOS? I use High Sierra.
If executed from the shell you can type

CTRL + Z


this will send the "terminal stop" signal (SIGTSTP) to the process and the system  won't schedule any more CPU time to the process.

You can then restart it by typing

fg


on the same shell.