Code

Ticket #6648: 6648_fix_random_number_generator_fcgi_fork-2.diff

File 6648_fix_random_number_generator_fcgi_fork-2.diff, 712 bytes (added by mitar, 3 years ago)

For Django 1.3+

Line 
1--- a/django/core/handlers/wsgi.py      2011-10-17 12:58:49.000000000 +0200
2+++ b/django/core/handlers/wsgi.py      2011-10-17 13:00:10.000000000 +0200
3@@ -1,5 +1,6 @@
4 from pprint import pformat
5 import sys
6+import random
7 from threading import Lock
8 try:
9     from cStringIO import StringIO
10@@ -244,6 +245,10 @@
11         if self._request_middleware is None:
12             self.initLock.acquire()
13             try:
14+                # Reseed random number generator, so that preforked processes
15+                # do not share the same seed
16+                random.seed()
17+
18                 try:
19                     # Check that middleware is still uninitialised.
20                     if self._request_middleware is None: