author | Florent <florent@secondweb.fr> |
Wed, 29 Apr 2009 17:36:49 +0200 | |
branch | tls-sprint |
changeset 1544 | d8fb60c56d69 |
parent 1543 | dca9817bb337 |
child 1936 | c5af2fbda5b6 |
permissions | -rw-r--r-- |
0 | 1 |
"""twisted server for CubicWeb web applications |
2 |
||
3 |
:organization: Logilab |
|
1016
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
151
diff
changeset
|
4 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
0 | 5 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
6 |
""" |
|
7 |
__docformat__ = "restructuredtext en" |
|
8 |
||
9 |
import sys |
|
10 |
import select |
|
1016
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
151
diff
changeset
|
11 |
from time import mktime |
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
151
diff
changeset
|
12 |
from datetime import date, timedelta |
1520
b097057e629d
provide an option to substitute the base-url (left-most part) subdomain by the one of the current http query to easy multiple subdomains website management
Florent <florent@secondweb.fr>
parents:
1420
diff
changeset
|
13 |
from urlparse import urlsplit, urlunsplit |
0 | 14 |
|
15 |
from twisted.application import service, strports |
|
16 |
from twisted.internet import reactor, task, threads |
|
17 |
from twisted.internet.defer import maybeDeferred |
|
18 |
from twisted.web2 import channel, http, server, iweb |
|
19 |
from twisted.web2 import static, resource, responsecode |
|
20 |
||
21 |
from cubicweb import ObjectNotFound |
|
1420
25c13e5b12bd
stop complaining about empty response, remove trailing spaces
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
22 |
from cubicweb.web import (AuthenticationError, NotFound, Redirect, |
0 | 23 |
RemoteCallFailed, DirectResponse, StatusResponse, |
24 |
ExplicitLogin) |
|
25 |
from cubicweb.web.application import CubicWebPublisher |
|
26 |
||
27 |
from cubicweb.etwist.request import CubicWebTwistedRequestAdapter |
|
28 |
||
29 |
||
30 |
def start_task(interval, func): |
|
31 |
lc = task.LoopingCall(func) |
|
32 |
lc.start(interval) |
|
33 |
||
34 |
def start_looping_tasks(repo): |
|
35 |
for interval, func in repo._looping_tasks: |
|
36 |
repo.info('starting twisted task %s with interval %.2fs', |
|
37 |
func.__name__, interval) |
|
38 |
def catch_error_func(repo=repo, func=func): |
|
39 |
try: |
|
40 |
func() |
|
41 |
except: |
|
42 |
repo.exception('error in looping task') |
|
43 |
start_task(interval, catch_error_func) |
|
44 |
# ensure no tasks will be further added |
|
45 |
repo._looping_tasks = () |
|
1420
25c13e5b12bd
stop complaining about empty response, remove trailing spaces
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
46 |
|
1543
dca9817bb337
fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
1542
diff
changeset
|
47 |
def host_prefixed_baseurl(baseurl, host): |
dca9817bb337
fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
1542
diff
changeset
|
48 |
scheme, netloc, url, query, fragment = urlsplit(baseurl) |
dca9817bb337
fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
1542
diff
changeset
|
49 |
netloc_domain = '.' + '.'.join(netloc.split('.')[-2:]) |
dca9817bb337
fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
1542
diff
changeset
|
50 |
if host.endswith(netloc_domain): |
dca9817bb337
fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
1542
diff
changeset
|
51 |
netloc = host |
dca9817bb337
fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
1542
diff
changeset
|
52 |
baseurl = urlunsplit((scheme, netloc, url, query, fragment)) |
dca9817bb337
fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
1542
diff
changeset
|
53 |
return baseurl |
dca9817bb337
fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
1542
diff
changeset
|
54 |
|
0 | 55 |
|
56 |
class LongTimeExpiringFile(static.File): |
|
57 |
"""overrides static.File and sets a far futre ``Expires`` date |
|
58 |
on the resouce. |
|
59 |
||
60 |
versions handling is done by serving static files by different |
|
61 |
URLs for each version. For instance:: |
|
62 |
||
63 |
http://localhost:8080/data-2.48.2/cubicweb.css |
|
64 |
http://localhost:8080/data-2.49.0/cubicweb.css |
|
65 |
etc. |
|
66 |
||
67 |
""" |
|
68 |
def renderHTTP(self, request): |
|
69 |
def setExpireHeader(response): |
|
70 |
response = iweb.IResponse(response) |
|
71 |
# Don't provide additional resource information to error responses |
|
72 |
if response.code < 400: |
|
73 |
# the HTTP RFC recommands not going further than 1 year ahead |
|
1016
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
151
diff
changeset
|
74 |
expires = date.today() + timedelta(days=6*30) |
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
151
diff
changeset
|
75 |
response.headers.setHeader('Expires', mktime(expires.timetuple())) |
0 | 76 |
return response |
77 |
d = maybeDeferred(super(LongTimeExpiringFile, self).renderHTTP, request) |
|
78 |
return d.addCallback(setExpireHeader) |
|
79 |
||
80 |
||
81 |
class CubicWebRootResource(resource.PostableResource): |
|
82 |
addSlash = False |
|
1420
25c13e5b12bd
stop complaining about empty response, remove trailing spaces
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
83 |
|
0 | 84 |
def __init__(self, config, debug=None): |
85 |
self.appli = CubicWebPublisher(config, debug=debug) |
|
86 |
self.debugmode = debug |
|
87 |
self.config = config |
|
88 |
self.base_url = config['base-url'] or config.default_base_url() |
|
89 |
self.versioned_datadir = 'data%s' % config.instance_md5_version() |
|
90 |
assert self.base_url[-1] == '/' |
|
91 |
self.https_url = config['https-url'] |
|
92 |
assert not self.https_url or self.https_url[-1] == '/' |
|
93 |
# when we have an in-memory repository, clean unused sessions every XX |
|
94 |
# seconds and properly shutdown the server |
|
95 |
if config.repo_method == 'inmemory': |
|
96 |
reactor.addSystemEventTrigger('before', 'shutdown', |
|
97 |
self.shutdown_event) |
|
1115 | 98 |
# monkey patch start_looping_task to get proper reactor integration |
0 | 99 |
self.appli.repo.__class__.start_looping_tasks = start_looping_tasks |
100 |
if config.pyro_enabled(): |
|
101 |
# if pyro is enabled, we have to register to the pyro name |
|
102 |
# server, create a pyro daemon, and create a task to handle pyro |
|
103 |
# requests |
|
104 |
self.pyro_daemon = self.appli.repo.pyro_register() |
|
105 |
self.pyro_listen_timeout = 0.02 |
|
106 |
start_task(1, self.pyro_loop_event) |
|
107 |
self.appli.repo.start_looping_tasks() |
|
108 |
try: |
|
109 |
self.url_rewriter = self.appli.vreg.select_component('urlrewriter') |
|
110 |
except ObjectNotFound: |
|
111 |
self.url_rewriter = None |
|
112 |
interval = min(config['cleanup-session-time'] or 120, |
|
113 |
config['cleanup-anonymous-session-time'] or 720) / 2. |
|
114 |
start_task(interval, self.appli.session_handler.clean_sessions) |
|
1420
25c13e5b12bd
stop complaining about empty response, remove trailing spaces
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
115 |
|
0 | 116 |
def shutdown_event(self): |
117 |
"""callback fired when the server is shutting down to properly |
|
118 |
clean opened sessions |
|
119 |
""" |
|
120 |
self.appli.repo.shutdown() |
|
121 |
||
122 |
def pyro_loop_event(self): |
|
123 |
"""listen for pyro events""" |
|
124 |
try: |
|
125 |
self.pyro_daemon.handleRequests(self.pyro_listen_timeout) |
|
126 |
except select.error: |
|
127 |
return |
|
1420
25c13e5b12bd
stop complaining about empty response, remove trailing spaces
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
128 |
|
0 | 129 |
def locateChild(self, request, segments): |
130 |
"""Indicate which resource to use to process down the URL's path""" |
|
131 |
if segments: |
|
132 |
if segments[0] == 'https': |
|
133 |
segments = segments[1:] |
|
134 |
if len(segments) >= 2: |
|
151
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
0
diff
changeset
|
135 |
if segments[0] in (self.versioned_datadir, 'data', 'static'): |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
0
diff
changeset
|
136 |
# Anything in data/, static/ is treated as static files |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
0
diff
changeset
|
137 |
if segments[0] == 'static': |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
0
diff
changeset
|
138 |
# instance static directory |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
0
diff
changeset
|
139 |
datadir = self.config.static_directory |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
0
diff
changeset
|
140 |
else: |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
0
diff
changeset
|
141 |
# cube static data file |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
0
diff
changeset
|
142 |
datadir = self.config.locate_resource(segments[1]) |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
0
diff
changeset
|
143 |
if datadir is None: |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
0
diff
changeset
|
144 |
return None, [] |
0 | 145 |
self.info('static file %s from %s', segments[-1], datadir) |
146 |
if segments[0] == 'data': |
|
147 |
return static.File(str(datadir)), segments[1:] |
|
148 |
else: |
|
149 |
return LongTimeExpiringFile(datadir), segments[1:] |
|
150 |
elif segments[0] == 'fckeditor': |
|
151 |
fckeditordir = self.config.ext_resources['FCKEDITOR_PATH'] |
|
152 |
return static.File(fckeditordir), segments[1:] |
|
153 |
# Otherwise we use this single resource |
|
154 |
return self, () |
|
1420
25c13e5b12bd
stop complaining about empty response, remove trailing spaces
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
155 |
|
0 | 156 |
def render(self, request): |
157 |
"""Render a page from the root resource""" |
|
158 |
# reload modified files (only in development or debug mode) |
|
159 |
if self.config.mode == 'dev' or self.debugmode: |
|
160 |
self.appli.vreg.register_objects(self.config.vregistry_path()) |
|
161 |
if self.config['profile']: # default profiler don't trace threads |
|
162 |
return self.render_request(request) |
|
163 |
else: |
|
164 |
return threads.deferToThread(self.render_request, request) |
|
1420
25c13e5b12bd
stop complaining about empty response, remove trailing spaces
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
165 |
|
0 | 166 |
def render_request(self, request): |
167 |
origpath = request.path |
|
168 |
host = request.host |
|
169 |
# dual http/https access handling: expect a rewrite rule to prepend |
|
170 |
# 'https' to the path to detect https access |
|
171 |
if origpath.split('/', 2)[1] == 'https': |
|
172 |
origpath = origpath[6:] |
|
173 |
request.uri = request.uri[6:] |
|
174 |
https = True |
|
1420
25c13e5b12bd
stop complaining about empty response, remove trailing spaces
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
175 |
baseurl = self.https_url or self.base_url |
0 | 176 |
else: |
177 |
https = False |
|
178 |
baseurl = self.base_url |
|
1520
b097057e629d
provide an option to substitute the base-url (left-most part) subdomain by the one of the current http query to easy multiple subdomains website management
Florent <florent@secondweb.fr>
parents:
1420
diff
changeset
|
179 |
if self.config['use-request-subdomain']: |
1543
dca9817bb337
fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
1542
diff
changeset
|
180 |
baseurl = host_prefixed_baseurl(baseurl, host) |
dca9817bb337
fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
1542
diff
changeset
|
181 |
self.warning('used baseurl is %s for this request', baseurl) |
0 | 182 |
req = CubicWebTwistedRequestAdapter(request, self.appli.vreg, https, baseurl) |
183 |
if req.authmode == 'http': |
|
184 |
# activate realm-based auth |
|
185 |
realm = self.config['realm'] |
|
186 |
req.set_header('WWW-Authenticate', [('Basic', {'realm' : realm })], raw=False) |
|
187 |
try: |
|
188 |
self.appli.connect(req) |
|
189 |
except AuthenticationError: |
|
190 |
return self.request_auth(req) |
|
191 |
except Redirect, ex: |
|
192 |
return self.redirect(req, ex.location) |
|
193 |
if https and req.cnx.anonymous_connection: |
|
194 |
# don't allow anonymous on https connection |
|
1420
25c13e5b12bd
stop complaining about empty response, remove trailing spaces
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
195 |
return self.request_auth(req) |
0 | 196 |
if self.url_rewriter is not None: |
1115 | 197 |
# XXX should occur before authentication? |
0 | 198 |
try: |
199 |
path = self.url_rewriter.rewrite(host, origpath) |
|
200 |
except Redirect, ex: |
|
201 |
return self.redirect(req, ex.location) |
|
202 |
request.uri.replace(origpath, path, 1) |
|
203 |
else: |
|
204 |
path = origpath |
|
205 |
if not path or path == "/": |
|
206 |
path = 'view' |
|
207 |
try: |
|
208 |
result = self.appli.publish(path, req) |
|
209 |
except DirectResponse, ex: |
|
210 |
return ex.response |
|
211 |
except StatusResponse, ex: |
|
212 |
return http.Response(stream=ex.content, code=ex.status, |
|
213 |
headers=req.headers_out or None) |
|
214 |
except RemoteCallFailed, ex: |
|
215 |
req.set_header('content-type', 'application/json') |
|
216 |
return http.Response(stream=ex.dumps(), |
|
217 |
code=responsecode.INTERNAL_SERVER_ERROR) |
|
218 |
except NotFound: |
|
219 |
result = self.appli.notfound_content(req) |
|
220 |
return http.Response(stream=result, code=responsecode.NOT_FOUND, |
|
221 |
headers=req.headers_out or None) |
|
222 |
except ExplicitLogin: # must be before AuthenticationError |
|
223 |
return self.request_auth(req) |
|
224 |
except AuthenticationError: |
|
225 |
if self.config['auth-mode'] == 'cookie': |
|
226 |
# in cookie mode redirecting to the index view is enough : |
|
227 |
# either anonymous connection is allowed and the page will |
|
228 |
# be displayed or we'll be redirected to the login form |
|
229 |
msg = req._('you have been logged out') |
|
230 |
if req.https: |
|
231 |
req._base_url = self.base_url |
|
232 |
req.https = False |
|
233 |
url = req.build_url('view', vid='index', __message=msg) |
|
234 |
return self.redirect(req, url) |
|
235 |
else: |
|
236 |
# in http we have to request auth to flush current http auth |
|
237 |
# information |
|
238 |
return self.request_auth(req, loggedout=True) |
|
239 |
except Redirect, ex: |
|
240 |
return self.redirect(req, ex.location) |
|
241 |
# request may be referenced by "onetime callback", so clear its entity |
|
242 |
# cache to avoid memory usage |
|
243 |
req.drop_entity_cache() |
|
244 |
return http.Response(stream=result, code=responsecode.OK, |
|
245 |
headers=req.headers_out or None) |
|
246 |
||
247 |
def redirect(self, req, location): |
|
248 |
req.headers_out.setHeader('location', str(location)) |
|
249 |
self.debug('redirecting to %s', location) |
|
250 |
# 303 See other |
|
251 |
return http.Response(code=303, headers=req.headers_out) |
|
1420
25c13e5b12bd
stop complaining about empty response, remove trailing spaces
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
252 |
|
0 | 253 |
def request_auth(self, req, loggedout=False): |
254 |
if self.https_url and req.base_url() != self.https_url: |
|
255 |
req.headers_out.setHeader('location', self.https_url + 'login') |
|
1420
25c13e5b12bd
stop complaining about empty response, remove trailing spaces
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
256 |
return http.Response(code=303, headers=req.headers_out) |
0 | 257 |
if self.config['auth-mode'] == 'http': |
258 |
code = responsecode.UNAUTHORIZED |
|
259 |
else: |
|
260 |
code = responsecode.FORBIDDEN |
|
261 |
if loggedout: |
|
262 |
if req.https: |
|
263 |
req._base_url = self.base_url |
|
264 |
req.https = False |
|
265 |
content = self.appli.loggedout_content(req) |
|
266 |
else: |
|
267 |
content = self.appli.need_login_content(req) |
|
268 |
return http.Response(code, req.headers_out, content) |
|
269 |
||
1420
25c13e5b12bd
stop complaining about empty response, remove trailing spaces
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
270 |
|
0 | 271 |
# This part gets run when you run this file via: "twistd -noy demo.py" |
272 |
def main(appid, cfgname): |
|
273 |
"""Starts an cubicweb twisted server for an application |
|
274 |
||
275 |
appid: application's identifier |
|
276 |
cfgname: name of the configuration to use (twisted or all-in-one) |
|
277 |
""" |
|
278 |
from cubicweb.cwconfig import CubicWebConfiguration |
|
279 |
from cubicweb.etwist import twconfig # trigger configuration registration |
|
280 |
config = CubicWebConfiguration.config_for(appid, cfgname) |
|
281 |
# XXX why calling init_available_cubes here ? |
|
282 |
config.init_available_cubes() |
|
283 |
# create the site and application objects |
|
284 |
if '-n' in sys.argv: # debug mode |
|
285 |
cubicweb = CubicWebRootResource(config, debug=True) |
|
286 |
else: |
|
287 |
cubicweb = CubicWebRootResource(config) |
|
288 |
#toplevel = vhost.VHostURIRewrite(base_url, cubicweb) |
|
289 |
toplevel = cubicweb |
|
290 |
website = server.Site(toplevel) |
|
291 |
application = service.Application("cubicweb") |
|
292 |
# serve it via standard HTTP on port set in the configuration |
|
293 |
s = strports.service('tcp:%04d' % (config['port'] or 8080), |
|
294 |
channel.HTTPFactory(website)) |
|
295 |
s.setServiceParent(application) |
|
296 |
return application |
|
297 |
||
298 |
||
299 |
from twisted.python import failure |
|
300 |
from twisted.internet import defer |
|
301 |
from twisted.web2 import fileupload |
|
302 |
||
303 |
# XXX set max file size to 100Mo: put max upload size in the configuration |
|
304 |
# line below for twisted >= 8.0, default param value for earlier version |
|
1420
25c13e5b12bd
stop complaining about empty response, remove trailing spaces
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
305 |
resource.PostableResource.maxSize = 100*1024*1024 |
0 | 306 |
def parsePOSTData(request, maxMem=100*1024, maxFields=1024, |
307 |
maxSize=100*1024*1024): |
|
308 |
if request.stream.length == 0: |
|
309 |
return defer.succeed(None) |
|
1420
25c13e5b12bd
stop complaining about empty response, remove trailing spaces
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
310 |
|
0 | 311 |
ctype = request.headers.getHeader('content-type') |
312 |
||
313 |
if ctype is None: |
|
314 |
return defer.succeed(None) |
|
315 |
||
316 |
def updateArgs(data): |
|
317 |
args = data |
|
318 |
request.args.update(args) |
|
319 |
||
320 |
def updateArgsAndFiles(data): |
|
321 |
args, files = data |
|
322 |
request.args.update(args) |
|
323 |
request.files.update(files) |
|
324 |
||
325 |
def error(f): |
|
326 |
f.trap(fileupload.MimeFormatError) |
|
327 |
raise http.HTTPError(responsecode.BAD_REQUEST) |
|
1420
25c13e5b12bd
stop complaining about empty response, remove trailing spaces
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
328 |
|
0 | 329 |
if ctype.mediaType == 'application' and ctype.mediaSubtype == 'x-www-form-urlencoded': |
330 |
d = fileupload.parse_urlencoded(request.stream, keep_blank_values=True) |
|
331 |
d.addCallbacks(updateArgs, error) |
|
332 |
return d |
|
333 |
elif ctype.mediaType == 'multipart' and ctype.mediaSubtype == 'form-data': |
|
334 |
boundary = ctype.params.get('boundary') |
|
335 |
if boundary is None: |
|
336 |
return defer.fail(http.HTTPError( |
|
337 |
http.StatusResponse(responsecode.BAD_REQUEST, |
|
338 |
"Boundary not specified in Content-Type."))) |
|
339 |
d = fileupload.parseMultipartFormData(request.stream, boundary, |
|
340 |
maxMem, maxFields, maxSize) |
|
341 |
d.addCallbacks(updateArgsAndFiles, error) |
|
342 |
return d |
|
343 |
else: |
|
344 |
raise http.HTTPError(responsecode.BAD_REQUEST) |
|
345 |
||
346 |
server.parsePOSTData = parsePOSTData |
|
347 |
||
348 |
||
349 |
from logging import getLogger |
|
350 |
from cubicweb import set_log_methods |
|
351 |
set_log_methods(CubicWebRootResource, getLogger('cubicweb.twisted')) |
|
352 |
||
353 |
||
354 |
||
355 |
def _gc_debug(): |
|
356 |
import gc |
|
357 |
from pprint import pprint |
|
358 |
from cubicweb.vregistry import VObject |
|
359 |
gc.collect() |
|
360 |
count = 0 |
|
361 |
acount = 0 |
|
362 |
ocount = {} |
|
363 |
for obj in gc.get_objects(): |
|
364 |
if isinstance(obj, CubicWebTwistedRequestAdapter): |
|
365 |
count += 1 |
|
366 |
elif isinstance(obj, VObject): |
|
367 |
acount += 1 |
|
368 |
else: |
|
369 |
try: |
|
1132 | 370 |
ocount[obj.__class__] += 1 |
0 | 371 |
except KeyError: |
372 |
ocount[obj.__class__] = 1 |
|
373 |
except AttributeError: |
|
374 |
pass |
|
375 |
print 'IN MEM REQUESTS', count |
|
376 |
print 'IN MEM APPOBJECTS', acount |
|
377 |
ocount = sorted(ocount.items(), key=lambda x: x[1], reverse=True)[:20] |
|
378 |
pprint(ocount) |
|
379 |
print 'UNREACHABLE', gc.garbage |