avoid multiple server_setup calls when multiple threads in use
This commit is contained in:
parent
59df6eb323
commit
22c112c0b1
1 changed files with 7 additions and 2 deletions
|
|
@ -27,6 +27,7 @@ import logging
|
|||
import os
|
||||
import sys
|
||||
import time
|
||||
import threading
|
||||
import traceback
|
||||
import pprint
|
||||
import resource
|
||||
|
|
@ -691,12 +692,16 @@ def server_setup(environ):
|
|||
#
|
||||
|
||||
firstcall = True
|
||||
firstcall_lock = threading.Lock()
|
||||
|
||||
def application(environ, start_response):
|
||||
global firstcall
|
||||
if firstcall:
|
||||
server_setup(environ)
|
||||
firstcall = False
|
||||
with firstcall_lock:
|
||||
# check again, another thread may be ahead of us
|
||||
if firstcall:
|
||||
server_setup(environ)
|
||||
firstcall = False
|
||||
# XMLRPC uses POST only. Reject anything else
|
||||
if environ['REQUEST_METHOD'] != 'POST':
|
||||
headers = [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue