mirror of
https://github.com/evennia/evennia.git
synced 2026-03-19 22:36:31 +01:00
Initial support for pypy + evennia
This commit is contained in:
parent
41859d9e46
commit
5cfff771f2
5 changed files with 59 additions and 37 deletions
|
|
@ -16,10 +16,12 @@ from src.server.sessionhandler import SESSIONS
|
|||
from src.typeclasses.typeclass import TypeClass
|
||||
from src.scripts.models import ScriptDB
|
||||
from src.comms import channelhandler
|
||||
from src.utils import logger
|
||||
from src.utils import logger, is_pypy
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
__all__ = ("Script", "DoNothing", "CheckSessions", "ValidateScripts", "ValidateChannelHandler", "ClearAttributeCache")
|
||||
__all__ = ["Script", "DoNothing", "CheckSessions", "ValidateScripts", "ValidateChannelHandler"]
|
||||
if not is_pypy:
|
||||
__all__.append("ClearAttributeCache")
|
||||
|
||||
_ATTRIBUTE_CACHE_MAXSIZE = settings.ATTRIBUTE_CACHE_MAXSIZE # attr-cache size in MB.
|
||||
|
||||
|
|
@ -446,16 +448,18 @@ class ValidateChannelHandler(Script):
|
|||
#print "ValidateChannelHandler run."
|
||||
channelhandler.CHANNELHANDLER.update()
|
||||
|
||||
class ClearAttributeCache(Script):
|
||||
"Clear the attribute cache."
|
||||
def at_script_creation(self):
|
||||
"Setup the script"
|
||||
self.key = "sys_cache_clear"
|
||||
self.desc = _("Clears the Attribute Cache")
|
||||
self.interval = 3600 * 2
|
||||
self.persistent = True
|
||||
def at_repeat(self):
|
||||
"called every 2 hours. Sets a max attr-cache limit to 100 MB." # enough for normal usage?
|
||||
attr_cache_size, _, _ = caches.get_cache_sizes()
|
||||
if attr_cache_size > _ATTRIBUTE_CACHE_MAXSIZE:
|
||||
caches.flush_attr_cache()
|
||||
# PyPy does not support sys.getsizeof, so the attribute cache dump script is skipped here.
|
||||
if not is_pypy:
|
||||
class ClearAttributeCache(Script):
|
||||
"Clear the attribute cache."
|
||||
def at_script_creation(self):
|
||||
"Setup the script"
|
||||
self.key = "sys_cache_clear"
|
||||
self.desc = _("Clears the Attribute Cache")
|
||||
self.interval = 3600 * 2
|
||||
self.persistent = True
|
||||
def at_repeat(self):
|
||||
"called every 2 hours. Sets a max attr-cache limit to 100 MB." # enough for normal usage?
|
||||
attr_cache_size, _, _ = caches.get_cache_sizes()
|
||||
if attr_cache_size > _ATTRIBUTE_CACHE_MAXSIZE:
|
||||
caches.flush_attr_cache()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue