Keeping the mac awake when running certain applications?

I use caffeine to avoid the system to sleep, you can configure the time is "awake" as well: http://lightheadsw.com/caffeine/

Edit to update as caffeine hasn't been updated for a long time, Amphetamine seems to work OK https://itunes.apple.com/us/app/amphetamine/id937984704?mt=12


You can use KeepingYouAwake. It is a free and lightweight menu bar utility for macOS (Version 10.10 and newer) that can prevent your Mac from entering sleep mode for a predefined duration or as long as it is activated.

It can be easily installed using Homebrew cask by running:

brew cask install keepingyouawake

It is an alternative to widely popular tool Caffeine from Lighthead Software. Caffeine hasn't been updated in a while. KeepingYouAwake's icons are Retina-compatible and do look nice in the dark themed menu bar.

Once you have activated KeepingYouAwake, you can simply lock the screen (by pressing Control + Command + q), turn down the screen brightness and remain assured that the system won't go to sleep!