def __init__(self, path, threaded=True, timeout=None):
super(LockBase, self).__init__(path)<EOL>self.lock_file = os.path.abspath(path) + "<STR_LIT>"<EOL>self.hostname = socket.gethostname()<EOL>self.pid = os.getpid()<EOL>if threaded:<EOL><INDENT>t = threading.current_thread()<EOL>ident = getattr(t, "<STR_LIT>", hash(t))<EOL>self.tname = "<STR_LIT>" % (ident & <NUM_LIT>)<EOL><DEDENT>else:<EOL><INDENT>self.tname = "<STR_LIT>"<EOL><DEDENT>dirname = os.path.dirname(self.lock_file)<EOL>self.unique_name = os.path.join(dirname,<EOL>"<STR_LIT>" % (self.hostname,<EOL>self.tname,<EOL>self.pid,<EOL>hash(self.path)))<EOL>self.timeout = timeout<EOL>
>>> lock = LockBase('somefile')
>>> lock = LockBase('somefile', threaded=False)