Create and verify pidfile. If the pidfile already exists the program exits with an error message, however if the process it refers to isn't running anymore, the pidfile is deleted and the program continues. This function will automatically install an :mod:`atexit` handler to re
(pidfile)
| 242 | |
| 243 | |
| 244 | def create_pidlock(pidfile): |
| 245 | """Create and verify pidfile. |
| 246 | |
| 247 | If the pidfile already exists the program exits with an error message, |
| 248 | however if the process it refers to isn't running anymore, the pidfile |
| 249 | is deleted and the program continues. |
| 250 | |
| 251 | This function will automatically install an :mod:`atexit` handler |
| 252 | to release the lock at exit, you can skip this by calling |
| 253 | :func:`_create_pidlock` instead. |
| 254 | |
| 255 | Returns: |
| 256 | Pidfile: used to manage the lock. |
| 257 | |
| 258 | Example: |
| 259 | >>> pidlock = create_pidlock('/var/run/app.pid') |
| 260 | """ |
| 261 | pidlock = _create_pidlock(pidfile) |
| 262 | atexit.register(pidlock.release) |
| 263 | return pidlock |
| 264 | |
| 265 | |
| 266 | def _create_pidlock(pidfile): |