equal
deleted
inserted
replaced
613 # A file that has been opened with posixfile can be renamed, so we rename |
613 # A file that has been opened with posixfile can be renamed, so we rename |
614 # f to a random temporary name before calling os.unlink on it. This allows |
614 # f to a random temporary name before calling os.unlink on it. This allows |
615 # callers to recreate f immediately while having other readers do their |
615 # callers to recreate f immediately while having other readers do their |
616 # implicit zombie filename blocking on a temporary name. |
616 # implicit zombie filename blocking on a temporary name. |
617 |
617 |
618 for tries in xrange(10): |
618 for tries in pycompat.xrange(10): |
619 temp = '%s-%08x' % (f, random.randint(0, 0xffffffff)) |
619 temp = '%s-%08x' % (f, random.randint(0, 0xffffffff)) |
620 try: |
620 try: |
621 os.rename(f, temp) # raises OSError EEXIST if temp exists |
621 os.rename(f, temp) # raises OSError EEXIST if temp exists |
622 break |
622 break |
623 except OSError as e: |
623 except OSError as e: |