| 2469 | |
| 2470 | real_mkdir = os.mkdir |
| 2471 | def my_mkdir(path, mode=0o777): |
| 2472 | path = str(path) |
| 2473 | # Emulate another process that would create the directory |
| 2474 | # just before we try to create it ourselves. We do it |
| 2475 | # in all possible pattern combinations, assuming that this |
| 2476 | # function is called at most 5 times (dirCPC/dir1/dir2, |
| 2477 | # dirCPC/dir1, dirCPC, dirCPC/dir1, dirCPC/dir1/dir2). |
| 2478 | if pattern.pop(): |
| 2479 | real_mkdir(path, mode) # From another process. |
| 2480 | concurrently_created.add(path) |
| 2481 | real_mkdir(path, mode) # Our real call. |
| 2482 | |
| 2483 | pattern = [bool(pattern_num & (1 << n)) for n in range(5)] |
| 2484 | concurrently_created = set() |