I need a function to generate/return a unique ID in a Python script, but I need it to satisfy a few requirements:
- Must be different every run
- Must be the same value within a single run, even if:
- Multiple classes call it
- Multiple threads (xdist) within one run call it
- All existing references to it fall out of scope
- If two instances of the script are running simultaneously, each instance gets its own ID.
I've looked at the uuid package, but it returns a different ID each time the methods are called. How can I have an ID be consistent throughout an entire run?