Attempt to acquire an exclusive lock on this record.
		
		If a timeout is given (in seconds) then the acquire call will block for up to that much time attempting to
		acquire the lock. If the lock can not be acquired (either because it is already set or we time out) a Locked
		exception will be raised.

def acquire(self, timeout=0, force=False):
		"""Attempt to acquire an exclusive lock on this record.
		
		If a timeout is given (in seconds) then the acquire call will block for up to that much time attempting to
		acquire the lock. If the lock can not be acquired (either because it is already set or we time out) a Locked
		exception will be raised.
		"""
		
		if timeout and not (self.Queue.__collection__ and self.Queue.__capped__):
			raise NotImplementedError(name(self.__class__) + ".Queue has not been prepared.")
		
		D = self.__class__
		collection = self.get_collection()
		identity = self.Lock()
		
		if force:
			query = D.id == self
		
		else:
			query = D.lock == None
			query |= D.lock.instance == identity.instance
			query |= D.lock.time < (identity.time - identity.__period__)
			query &= D.id == self
		
		previous = collection.find_one_and_update(query, {'$set': {~D.lock: identity}}, {~D.lock: True})
		
		if previous is None:
			if timeout:
				try:
					self.wait(timeout)
				except TimeoutError:
					pass
				
				return self.acquire()
			
			lock = getattr(self.find_one(self, projection={~D.lock: True}), 'lock', None)
			raise self.Locked("Unable to acquire lock.", lock)
		
		if not force and ~D.lock in previous:
			previous = self.Lock.from_mongo(previous.get(~D.lock))
			
			if previous:
				if previous.expires < identity.time:
					previous.expired(self)
				
				if previous.instance != identity.instance:  # Dont re-broadcast acquisition of an already-held lock.
					identity.acquired(self, force)
		
		return identity