Replace the guppy library with Pympler
This commit is contained in:
@@ -392,12 +392,11 @@ def ccache():
|
|||||||
cache.disk.clear()
|
cache.disk.clear()
|
||||||
session.flash += T("Disk Cleared")
|
session.flash += T("Disk Cleared")
|
||||||
redirect(URL(r=request))
|
redirect(URL(r=request))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from guppy import hpy
|
from pympler.asizeof import asizeof
|
||||||
hp = hpy()
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
hp = False
|
asizeof = False
|
||||||
|
|
||||||
import shelve
|
import shelve
|
||||||
import os
|
import os
|
||||||
@@ -451,9 +450,9 @@ def ccache():
|
|||||||
ram['ratio'] = 0
|
ram['ratio'] = 0
|
||||||
|
|
||||||
for key, value in iteritems(cache.ram.storage):
|
for key, value in iteritems(cache.ram.storage):
|
||||||
if hp:
|
if asizeof:
|
||||||
ram['bytes'] += hp.iso(value[1]).size
|
ram['bytes'] += asizeof(value[1])
|
||||||
ram['objects'] += hp.iso(value[1]).count
|
ram['objects'] += 1
|
||||||
ram['entries'] += 1
|
ram['entries'] += 1
|
||||||
if value[0] < ram['oldest']:
|
if value[0] < ram['oldest']:
|
||||||
ram['oldest'] = value[0]
|
ram['oldest'] = value[0]
|
||||||
@@ -469,9 +468,9 @@ def ccache():
|
|||||||
except (KeyError, ZeroDivisionError):
|
except (KeyError, ZeroDivisionError):
|
||||||
disk['ratio'] = 0
|
disk['ratio'] = 0
|
||||||
else:
|
else:
|
||||||
if hp:
|
if asizeof:
|
||||||
disk['bytes'] += hp.iso(value[1]).size
|
disk['bytes'] += asizeof(value[1])
|
||||||
disk['objects'] += hp.iso(value[1]).count
|
disk['objects'] += 1
|
||||||
disk['entries'] += 1
|
disk['entries'] += 1
|
||||||
if value[0] < disk['oldest']:
|
if value[0] < disk['oldest']:
|
||||||
disk['oldest'] = value[0]
|
disk['oldest'] = value[0]
|
||||||
@@ -511,7 +510,7 @@ def ccache():
|
|||||||
total['keys'] = key_table(total['keys'])
|
total['keys'] = key_table(total['keys'])
|
||||||
|
|
||||||
return dict(form=form, total=total,
|
return dict(form=form, total=total,
|
||||||
ram=ram, disk=disk, object_stats=hp != False)
|
ram=ram, disk=disk, object_stats=asizeof != False)
|
||||||
|
|
||||||
|
|
||||||
def table_template(table):
|
def table_template(table):
|
||||||
|
|||||||
@@ -148,7 +148,7 @@
|
|||||||
{{=T.M("(**%.0d MB**)", total['bytes'] / 1048576)}}
|
{{=T.M("(**%.0d MB**)", total['bytes'] / 1048576)}}
|
||||||
{{pass}}
|
{{pass}}
|
||||||
{{else:}}
|
{{else:}}
|
||||||
{{=T.M("**not available** (requires the Python [[guppy http://pypi.python.org/pypi/guppy/ popup]] library)")}}
|
{{=T.M("**not available** (requires the Python [[Pympler https://pypi.python.org/pypi/Pympler popup]] library)")}}
|
||||||
{{pass}}
|
{{pass}}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
@@ -176,7 +176,7 @@
|
|||||||
{{=T.M("(**%.0d MB**)", ram['bytes'] / 10485576)}}
|
{{=T.M("(**%.0d MB**)", ram['bytes'] / 10485576)}}
|
||||||
{{pass}}
|
{{pass}}
|
||||||
{{else:}}
|
{{else:}}
|
||||||
{{=T.M("``**not available**``:red (requires the Python [[guppy http://pypi.python.org/pypi/guppy/ popup]] library)")}}
|
{{=T.M("``**not available**``:red (requires the Python [[Pympler https://pypi.python.org/pypi/Pympler popup]] library)")}}
|
||||||
{{pass}}
|
{{pass}}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
@@ -205,7 +205,7 @@
|
|||||||
{{=T.M("(**%.0d MB**)", disk['bytes'] / 1048576)}}
|
{{=T.M("(**%.0d MB**)", disk['bytes'] / 1048576)}}
|
||||||
{{pass}}
|
{{pass}}
|
||||||
{{else:}}
|
{{else:}}
|
||||||
{{=T.M("``**not available**``:red (requires the Python [[guppy http://pypi.python.org/pypi/guppy/ popup]] library)")}}
|
{{=T.M("``**not available**``:red (requires the Python [[Pympler https://pypi.python.org/pypi/Pympler popup]] library)")}}
|
||||||
{{pass}}
|
{{pass}}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
Reference in New Issue
Block a user