()
| 62 | |
| 63 | |
| 64 | def _reseed_random() -> None: |
| 65 | if "random" not in sys.modules: |
| 66 | return |
| 67 | import random |
| 68 | |
| 69 | # If os.urandom is available, this method does the same thing as |
| 70 | # random.seed (at least as of python 2.6). If os.urandom is not |
| 71 | # available, we mix in the pid in addition to a timestamp. |
| 72 | try: |
| 73 | seed = int(hexlify(os.urandom(16)), 16) |
| 74 | except NotImplementedError: |
| 75 | seed = int(time.time() * 1000) ^ os.getpid() |
| 76 | random.seed(seed) |
| 77 | |
| 78 | |
| 79 | _task_id = None |