equal
deleted
inserted
replaced
1 # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
1 # copyright 2003-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
3 # |
3 # |
4 # This file is part of CubicWeb. |
4 # This file is part of CubicWeb. |
5 # |
5 # |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
15 # |
15 # |
16 # You should have received a copy of the GNU Lesser General Public License along |
16 # You should have received a copy of the GNU Lesser General Public License along |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 """twisted server for CubicWeb web instances""" |
18 """twisted server for CubicWeb web instances""" |
19 |
19 |
20 |
|
21 import sys |
20 import sys |
22 import select |
|
23 import traceback |
21 import traceback |
24 import threading |
22 import threading |
25 from cgi import FieldStorage, parse_header |
23 from cgi import FieldStorage, parse_header |
26 |
|
27 from six.moves.urllib.parse import urlsplit, urlunsplit |
|
28 |
24 |
29 from cubicweb.statsd_logger import statsd_timeit |
25 from cubicweb.statsd_logger import statsd_timeit |
30 |
26 |
31 from twisted.internet import reactor, task, threads |
27 from twisted.internet import reactor, task, threads |
32 from twisted.web import http, server |
28 from twisted.web import http, server |
41 from cubicweb.utils import json_dumps |
37 from cubicweb.utils import json_dumps |
42 from cubicweb.web import DirectResponse |
38 from cubicweb.web import DirectResponse |
43 from cubicweb.web.application import CubicWebPublisher |
39 from cubicweb.web.application import CubicWebPublisher |
44 from cubicweb.etwist.request import CubicWebTwistedRequestAdapter |
40 from cubicweb.etwist.request import CubicWebTwistedRequestAdapter |
45 from cubicweb.etwist.http import HTTPResponse |
41 from cubicweb.etwist.http import HTTPResponse |
|
42 |
46 |
43 |
47 def start_task(interval, func): |
44 def start_task(interval, func): |
48 lc = task.LoopingCall(func) |
45 lc = task.LoopingCall(func) |
49 # wait until interval has expired to actually start the task, else we have |
46 # wait until interval has expired to actually start the task, else we have |
50 # to wait all tasks to be finished for the server to be actually started |
47 # to wait all tasks to be finished for the server to be actually started |