'Acquire the \'write\' lock.'

def acquire_write_lock(self, wait=True):

    self.condition.acquire()
    try:
        if wait:
            while (self.current_sync_operation is not None):
                self.condition.wait()
        elif (self.current_sync_operation is not None):
            return False
        self.current_sync_operation = threading.currentThread()
        if (self.async > 0):
            if wait:
                self.condition.wait()
            else:
                self.current_sync_operation = None
                return False
        log.debug('%s    acquired    write    lock', self)
    finally:
        self.condition.release()
    if (not wait):
        return True
