Some minor cleanups.
This commit is contained in:
parent
88f327ba40
commit
11d1114f61
4 changed files with 19 additions and 19 deletions
|
|
@ -16,12 +16,12 @@ matter the value of this file.
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
from subprocess import Popen
|
from subprocess import Popen
|
||||||
import Queue, thread
|
import Queue, thread
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
# check if launched with pypy
|
||||||
import __pypy__ as is_pypy
|
import __pypy__ as is_pypy
|
||||||
except ImportError:
|
except ImportError:
|
||||||
is_pypy = False
|
is_pypy = False
|
||||||
|
|
@ -30,7 +30,6 @@ except ImportError:
|
||||||
# System Configuration
|
# System Configuration
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
SERVER_PIDFILE = "server.pid"
|
SERVER_PIDFILE = "server.pid"
|
||||||
PORTAL_PIDFILE = "portal.pid"
|
PORTAL_PIDFILE = "portal.pid"
|
||||||
|
|
||||||
|
|
@ -168,7 +167,6 @@ def start_services(server_argv, portal_argv):
|
||||||
else:
|
else:
|
||||||
# normal operation: start portal as a daemon; we don't care to monitor it for restart
|
# normal operation: start portal as a daemon; we don't care to monitor it for restart
|
||||||
PORTAL = Popen(portal_argv)
|
PORTAL = Popen(portal_argv)
|
||||||
|
|
||||||
except IOError, e:
|
except IOError, e:
|
||||||
print "Portal IOError: %s\nA possible explanation for this is that 'twistd' is not found." % e
|
print "Portal IOError: %s\nA possible explanation for this is that 'twistd' is not found." % e
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -694,7 +694,7 @@ class CmdServerLoad(MuxCommand):
|
||||||
|
|
||||||
if not is_pypy:
|
if not is_pypy:
|
||||||
# Cache size measurements are not available on PyPy because it lacks sys.getsizeof
|
# Cache size measurements are not available on PyPy because it lacks sys.getsizeof
|
||||||
|
|
||||||
# object cache size
|
# object cache size
|
||||||
cachedict = _idmapper.cache_size()
|
cachedict = _idmapper.cache_size()
|
||||||
totcache = cachedict["_total"]
|
totcache = cachedict["_total"]
|
||||||
|
|
|
||||||
|
|
@ -448,18 +448,19 @@ class ValidateChannelHandler(Script):
|
||||||
#print "ValidateChannelHandler run."
|
#print "ValidateChannelHandler run."
|
||||||
channelhandler.CHANNELHANDLER.update()
|
channelhandler.CHANNELHANDLER.update()
|
||||||
|
|
||||||
# PyPy does not support sys.getsizeof, so the attribute cache dump script is skipped here.
|
class ClearAttributeCache(Script):
|
||||||
if not is_pypy:
|
"Clear the attribute cache."
|
||||||
class ClearAttributeCache(Script):
|
def at_script_creation(self):
|
||||||
"Clear the attribute cache."
|
"Setup the script"
|
||||||
def at_script_creation(self):
|
self.key = "sys_cache_clear"
|
||||||
"Setup the script"
|
self.desc = _("Clears the Attribute Cache")
|
||||||
self.key = "sys_cache_clear"
|
self.interval = 3600 * 2
|
||||||
self.desc = _("Clears the Attribute Cache")
|
self.persistent = True
|
||||||
self.interval = 3600 * 2
|
def at_repeat(self):
|
||||||
self.persistent = True
|
"called every 2 hours. Sets a max attr-cache limit to 100 MB." # enough for normal usage?
|
||||||
def at_repeat(self):
|
if is_pypy:
|
||||||
"called every 2 hours. Sets a max attr-cache limit to 100 MB." # enough for normal usage?
|
# pypy don't support get_size, so we have to skip out here.
|
||||||
attr_cache_size, _, _ = caches.get_cache_sizes()
|
return
|
||||||
if attr_cache_size > _ATTRIBUTE_CACHE_MAXSIZE:
|
attr_cache_size, _, _ = caches.get_cache_sizes()
|
||||||
caches.flush_attr_cache()
|
if attr_cache_size > _ATTRIBUTE_CACHE_MAXSIZE:
|
||||||
|
caches.flush_attr_cache()
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
# simple check to determine if we are currently running under pypy.
|
||||||
try:
|
try:
|
||||||
import __pypy__ as is_pypy
|
import __pypy__ as is_pypy
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue