<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def prolong(self):
 		"""Prolong the working duration of an already held lock. 		 		Attempting to prolong a lock not already owned will result in a Locked exception. 		"""

		
		D = self.__class__
		collection = self.get_collection()
		identity = self.Lock()
		
		query = D.id == self
		query &= D.lock.instance == identity.instance
		query &= D.lock.time >= (identity.time - identity.__period__)
		
		previous = collection.find_one_and_update(query, {'$set': {~D.lock.time: identity.time}}, {~D.lock: True})
		
		if previous is None:
			lock = getattr(self.find_one(self, projection={~D.lock: True}), 'lock', None)
			
			if lock and lock.expires <= identity.time:
				lock.expired(self)
			
			raise self.Locked("Unable to prolong lock.", lock)
		
		identity.prolonged(self)
		
		return identity