MacOS – Mountain Lion sleeps too aggressively

adobe-lightroommacospower-managementsleep-wake

For me, Mountain Lion always seems to sleep whenever there is no user action, even when the computer is still doing something. In my case it always sleeps in the middle of running a batch operation in Lightroom 4.1, and it has slept while Time Machine is still cleaning up.

According to Siracusa's ML review, apps need to be written to make "power assertions" if they want to stop the computer from sleeping. Otherwise, sleep it will. This seems like a way too aggressive strategy, especially to implement by default in a new OS? There must be many, many apps that have not been written to make these power assertions (including it seems parts of Apple's own Time Machine backup process).

Is there a hidden preference somewhere to revert to the old method of sleep at least until we get better app support for this? I'm not looking for a solution to supress sleep entirely (I know I can just tell the computer to never sleep), but rather to stop sleeping while it's still doing something.

Additional info:

  1. My Mac does not support Power Nap (mid 2009 13" MBP)
  2. My power settings in system preferences are set to the default, as follows:

pmset -g:

Active Profiles:
Battery Power       -1*
AC Power        -1
Currently in use:
 hibernatemode        0
 acwake               0
 lidwake              1
 halfdim              1
 sleep                10
 ttyskeepawake        1
 sms                  1
 hibernatefile        /var/vm/sleepimage
 disksleep            10
 displaysleep         2

pmset -g cap:

Capabilities for Battery Power:
 displaysleep
 disksleep
 sleep
 acwake
 lidwake
 lessbright
 halfdim
 sms
 ttyskeepawake
 hibernatemode
 hibernatefile

System log before and after a particular problematic sleep state (subsequent wake was not due to user input but rather a "DarkWake"):

    2012-07-27 00:32:07.343 com.apple.launchd[1]: (com.apple.iCloudHelper[3859]) Exited: Killed: 9
    2012-07-27 00:32:07.000 kernel[0]: memorystatus_thread: idle exiting pid 3859 [com.apple.iCloud]
    2012-07-27 00:32:12.416 com.apple.time[13]: Next maintenance wake [Backup Interval]: <date: 0x7fea7b6235f0> Fri Jul 27 00:45:48 2012 CEST (approx)
    2012-07-27 00:32:12.416 com.apple.time[13]: Requesting maintenance wake [Backup Interval]: <date: 0x7fea7b6235f0> Fri Jul 27 00:45:48 2012 CEST (approx)
    2012-07-27 00:32:13.000 kernel[0]: AirPort_Brcm43xx::powerChange: System Sleep 
    2012-07-27 00:32:14.000 kernel[0]: 00000000  00000020  NVEthernet::setLinkStatus - not Active
    2012-07-27 02:20:14.000 kernel[0]: Wake reason: RTC (Alarm)
    2012-07-27 02:20:14.000 kernel[0]: RTC: Maintenance 2012/7/27 00:20:13, sleep 2012/7/26 22:32:15
    2012-07-27 02:20:14.000 kernel[0]: AirPort_Brcm43xx::powerChange: System Wake - Full Wake/ Dark Wake / Maintenance wake

Best Answer

caffeinate -i open -W -a Lightroom.app

should keep the system awake as long as Lightroom is running and not idle. To prevent any sleep at all, use -s instead of -i.