3 ms·
I've definitely seen this practice, the solution I saw to "fix" this: after 20 attempts fail. Silently. It was a static file, but it didn't track last file crea
by Forge36 8y ago
I've definitely seen this practice, the solution I saw to "fix" this: after 20 attempts fail. Silently.
It was a static file, but it didn't track last file created (of course someone had copied this static file... But that's a separate problem).
- blattimwind 8y agowhile True: fd = open(log-$timestamp-$pid-$randomhex, O_CREAT|O_EXCL) if fd: break Hypothetically unbounded runtime, O(1) in practice.
- WorldMaker 8y agoDon't even bother with the while True. If you get a bucket collision with a random number, just don't log anything, or just fatally crash because you can't trust the platform's PRNG or don't have enough available entropy or are just plain unlucky. Keep it proper O(1).