Ticket #6648: 6648_fix_random_number_generator_fcgi_fork.diff

File 6648_fix_random_number_generator_fcgi_fork.diff, 785 bytes (added by peritus <peritus@…>, 7 years ago)

Resets the random number generator's seed for each fcgi-child

  • django/core/handlers/wsgi.py

    diff --git a/django/core/handlers/wsgi.py b/django/core/handlers/wsgi.py
    index 765600d..0d9ec1a 100644
    a b class WSGIHandler(base.BaseHandler): 
    206206        # settings weren't available.
    207207        if self._request_middleware is None:
    208208            self.initLock.acquire()
     209
     210            # reset pseudo random number generator, so preforked processes
     211            # won't start with the same (time-based) seed.
     212            from os import getpid
     213            from time import ctime
     214            import random
     215
     216            random.seed("%d%s" % (getpid(), ctime()))
     217
    209218            # Check that middleware is still uninitialised.
    210219            if self._request_middleware is None:
    211220                self.load_middleware()
Back to Top