|
@@ -75,16 +75,23 @@ class LodelWSGIHandler(wsgiref.simple_server.WSGIRequestHandler):
|
75
|
75
|
self.request.close()
|
76
|
76
|
super().close()
|
77
|
77
|
|
78
|
|
-##@brief WSGIServer implementing ForkingTCPServer.
|
79
|
|
-#
|
80
|
|
-#Same features than wsgiref.simple_server.WSGIServer but process each requests
|
81
|
|
-#in a child process
|
82
|
|
-class ForkingWSGIServer(
|
83
|
|
- wsgiref.simple_server.WSGIServer, socketserver.ForkingTCPServer):
|
84
|
|
-
|
|
78
|
+
|
|
79
|
+class CustomForkingTCPServer(socketserver.ForkingTCPServer):
|
85
|
80
|
##@brief static property indicating the max number of childs allowed
|
86
|
81
|
max_children = 40
|
87
|
82
|
|
|
83
|
+ def __init__(self, *args, **kwargs):
|
|
84
|
+ super().__init__(*args, **kwargs)
|
|
85
|
+ if self.__class__.active_children is None:
|
|
86
|
+ self.__class__.active_childer = set()
|
|
87
|
+
|
|
88
|
+ ##@brief Implements max_children limitations
|
|
89
|
+ def process_request(self, request, client_address):
|
|
90
|
+ while self.active_children is not None and \
|
|
91
|
+ len(self.active_children) > self.__class__.max_children:
|
|
92
|
+ self.collect_children()
|
|
93
|
+ super().process_request(request, client_address)
|
|
94
|
+
|
88
|
95
|
##@brief Custom reimplementation of shutdown method in order to ensure
|
89
|
96
|
#that we close all listening sockets
|
90
|
97
|
#
|
|
@@ -107,6 +114,15 @@ class ForkingWSGIServer(
|
107
|
114
|
self.active_children.discard(pid)
|
108
|
115
|
self.server_close()
|
109
|
116
|
|
|
117
|
+##@brief WSGIServer implementing ForkingTCPServer.
|
|
118
|
+#
|
|
119
|
+#Same features than wsgiref.simple_server.WSGIServer but process each requests
|
|
120
|
+#in a child process
|
|
121
|
+class ForkingWSGIServer(
|
|
122
|
+ wsgiref.simple_server.WSGIServer, CustomForkingTCPServer):
|
|
123
|
+ pass
|
|
124
|
+
|
|
125
|
+
|
110
|
126
|
##@brief utility function to extract site id from an url
|
111
|
127
|
def site_id_from_url(url):
|
112
|
128
|
res = ''
|