'Sleep a given time in 1 second intervals.
When a machine is suspended during a time.sleep(n) call for more
than n seconds, sometimes the sleep is interrupted and all threads
wake up at the same time. This leads to race conditions between
the threads issuing the heartbeat and the one checking for it. By
sleeping in small intervals, we make sure that even if one sleep
call is interrupted, we do not check for the heartbeat too early.
Args:
seconds: Number of seconds to sleep.
Raises:
MemoryError: if the process exceeds memory quota.'

def Sleep(self, seconds):

    time.sleep((seconds - int(seconds)))
    for _ in xrange(int(seconds)):
        time.sleep(1)
        if (self.GetMemoryUsage() > self.memory_quota):
            raise MemoryError('Exceeded    memory    allowance.')
