| 1314 | mypid = os.getpid() |
| 1315 | |
| 1316 | def try_remove_lockfile(): |
| 1317 | # in a fork() situation, only the last process should |
| 1318 | # remove the .lock, otherwise the other processes run the |
| 1319 | # risk of seeing their temporary dir disappear. For now |
| 1320 | # we remove the .lock in the parent only (i.e. we assume |
| 1321 | # that the children finish before the parent). |
| 1322 | if os.getpid() != mypid: |
| 1323 | return |
| 1324 | try: |
| 1325 | lockfile.remove() |
| 1326 | except error.Error: |
| 1327 | pass |
| 1328 | |
| 1329 | atexit.register(try_remove_lockfile) |
| 1330 | |