def ensure_vm_not_started(self):
        """
        Though it should never happen, this function makes sure that the VM is not already
        running, which would prevent proper initialization.
        """
        if DEBUG:
            print "ensure_vm_not_started"
        start_time = time.time()
        while self.vm.is_alive_vm():
            if DEBUG:
                print "VM is alive. Killing..."
            self.vm.kill_vm()
            elapsed = time.time() - start_time
            if elapsed > 20:
                raise Exception("It was not possible to ensure that the machine is powered off")
        
    #TODO: Consider whether this should indeed be threaded, and in that case, consider what would happen
    # if an experiment was started with this function still running, after dispose has returned.
    #@threaded()
dataset/ETHPy150Open weblabdeusto/weblabdeusto/server/src/experiments/vm/server.py/VMExperiment.ensure_vm_not_started/original