human
Complete this python program:
def locked(func):
assistant
#Here is the Python code you requested.

    """Decorator which locks self.lock.
    """
    def nested(self, *args, **kwargs):
        self.lock.acquire()
        try:
            return func(self, *args, **kwargs)
        finally:
            self.lock.release()
    return nested