-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uuid
's fast-rng
feature doesn't mesh with python's frequent use of fork
#42
Comments
This looks very interesting, I was thinking maybe the uuid-rs crate should make use of
|
Oh yeah, that does seem to be the case - three uuids and then they diverge import uuid_utils
import os
uuid_utils.uuid4()
os.fork()
for ix in range(5):
b = uuid_utils.uuid4()
print(f"{ix} = {b}")
strace confirms as much
|
FYI rand's |
We've been debugging an issue today after introducing uuid-utils into our backend workers, which use Celery. Celery workers use
fork(2)
(at least in some configurations) to spin up worker processes.The
rand
crate, which rust'suuid
crate uses if you pass thefast-rng
crate, doesn't seem to reseed the RNG on a fork. In Rust land, I suppose this normally isn't an issue because it seems pretty rare to use fork. In python, it's a lot more common, causing a situation where the rng isn't reseeded when forking out celery workers.Enjoy some repros:
I suppose this is technically not a bug, I'm just interested in your take on this. Ultimately it's kind of a culture issue that python forks, but as of now it's a tradeoff between the "just works"-ness of this as a library and generating uuids very quickly.
Versions
The text was updated successfully, but these errors were encountered: