How do I prevent my iMac from sleeping while media is being played or streamed? I know this problem has been around for a while. With the release of Mountain Lion Macs got the bad habit of falling to sleep when they are not used by a human.

My iMac falls to sleep when I walk away for a while. Even when the system should be busy with downloading files and converting videos. It just goes to sleep no matter what.

With an Apple TV its even worse. I got used to restarting iTunes before I started watching a movie to reset the connection but with the release of iTunes 11 the Mac even falls to sleep while I am already watching the movie! I have wake on lan activated like the Apple support side say but it just doesn't matter.

Sometimes I use the Caffein App to keep my Mac awake but most of the time I forget to do so and Apple TV just cuts the connection when the Mac went to sleep again.

Is there any permanent solution for the kind of bad behavior?
I experienced exactly the same issue. The steps to resolve the issue were the following:


delete /Library/Preferences/SystemConfiguration/com.apple.PowerManagement.plist
reboot


If it won't solve it another helpful step could be resetting the SMC: http://support.apple.com/kb/HT3964?viewlocale=en_US