Is there a (programmatic) way to prevent my Linux (Ubuntu) from going into sleep mode while my Python program is running? I seek a solution that avoids me manually changing the OS power settings each time I run my code.
Background: I'm running a long machine learning training from within PyCharm (using Ray RLlib). While I would have hoped for the intense active process to prevent the sleeping, my Ubuntu falls asleep after my standard power settings' suspension period is up if I don't interact during the training.
I am surprised to not find any solution when googling and looking at Stackoverflow; it would seem such a common need for Python (or maybe other) programmers, and I would have expected some python tools to exist to readily allow to prevent the sleeping from within my Python script itself.
I found SetThreadExecutionState for Windows (with C++), but nothing so far for Linux. A slightly less focused question Prevent sleep mode python (Wakelock on python) is also related to my issue, but it has not attracted any answer solving the case for the Linux OS.