def acquire(self):
try:<EOL><INDENT>pidfile = open(self._pidfile, "<STR_LIT:a>")<EOL><DEDENT>except IOError as err:<EOL><INDENT>raise SystemExit(err)<EOL><DEDENT>try:<EOL><INDENT>fcntl.flock(pidfile.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)<EOL><DEDENT>except IOError:<EOL><INDENT>raise SystemExit('<STR_LIT>' + self._pidfile)<EOL><DEDENT>pidfile.seek(<NUM_LIT:0>)<EOL>pidfile.truncate()<EOL>pidfile.write(str(os.getpid()) + '<STR_LIT:\n>')<EOL>pidfile.flush()<EOL>self.pidfile = pidfile<EOL>atexit.register(self.release)<EOL>
Acquire the pidfile.

        Create the pidfile, lock it, write the pid into it
        and register the release with atexit.


        :return: None
        :raise: SystemExit