<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def locked(path, timeout=None):
 """Decorator which enables locks for decorated function. Arguments: - path: path for lockfile. - timeout (optional):
 Timeout for acquiring lock. Usage: @locked('/var/run/myname', timeout=0) """

    def decor(func):
        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            lock = FileLock(path, timeout=timeout)
            lock.acquire()
            try:
                return func(*args, **kwargs)
            finally:
                lock.release()
        return wrapper
    return decor