Merge branch 'master' into develop
This commit is contained in:
commit
8f11b38422
6 changed files with 31 additions and 7 deletions
|
|
@ -105,6 +105,7 @@ _IDMAPPER_CACHE_MAXSIZE = settings.IDMAPPER_CACHE_MAXSIZE
|
|||
_GAMETIME_MODULE = None
|
||||
|
||||
_IDLE_TIMEOUT = settings.IDLE_TIMEOUT
|
||||
_LAST_SERVER_TIME_SNAPSHOT = 0
|
||||
|
||||
|
||||
def _server_maintenance():
|
||||
|
|
@ -113,6 +114,8 @@ def _server_maintenance():
|
|||
the server needs to do. It is called every minute.
|
||||
"""
|
||||
global EVENNIA, _MAINTENANCE_COUNT, _FLUSH_CACHE, _GAMETIME_MODULE
|
||||
global _LAST_SERVER_TIME_SNAPSHOT
|
||||
|
||||
if not _FLUSH_CACHE:
|
||||
from evennia.utils.idmapper.models import conditional_flush as _FLUSH_CACHE
|
||||
if not _GAMETIME_MODULE:
|
||||
|
|
@ -125,8 +128,13 @@ def _server_maintenance():
|
|||
# first call after a reload
|
||||
_GAMETIME_MODULE.SERVER_START_TIME = now
|
||||
_GAMETIME_MODULE.SERVER_RUNTIME = ServerConfig.objects.conf("runtime", default=0.0)
|
||||
_LAST_SERVER_TIME_SNAPSHOT = now
|
||||
else:
|
||||
_GAMETIME_MODULE.SERVER_RUNTIME += 60.0
|
||||
# adjust the runtime not with 60s but with the actual elapsed time
|
||||
# in case this may varies slightly from 60s.
|
||||
_GAMETIME_MODULE.SERVER_RUNTIME += (now - _LAST_SERVER_TIME_SNAPSHOT)
|
||||
_LAST_SERVER_TIME_SNAPSHOT = now
|
||||
|
||||
# update game time and save it across reloads
|
||||
_GAMETIME_MODULE.SERVER_RUNTIME_LAST_UPDATED = now
|
||||
ServerConfig.objects.conf("runtime", _GAMETIME_MODULE.SERVER_RUNTIME)
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ class TestServer(TestCase):
|
|||
connection=DEFAULT,
|
||||
_IDMAPPER_CACHE_MAXSIZE=1000,
|
||||
_MAINTENANCE_COUNT=3600 - 1,
|
||||
_LAST_SERVER_TIME_SNAPSHOT=0,
|
||||
ServerConfig=DEFAULT,
|
||||
) as mocks:
|
||||
mocks["connection"].close = MagicMock()
|
||||
|
|
@ -84,6 +85,7 @@ class TestServer(TestCase):
|
|||
connection=DEFAULT,
|
||||
_IDMAPPER_CACHE_MAXSIZE=1000,
|
||||
_MAINTENANCE_COUNT=3700 - 1,
|
||||
_LAST_SERVER_TIME_SNAPSHOT=0,
|
||||
ServerConfig=DEFAULT,
|
||||
) as mocks:
|
||||
mocks["connection"].close = MagicMock()
|
||||
|
|
@ -101,6 +103,7 @@ class TestServer(TestCase):
|
|||
connection=DEFAULT,
|
||||
_IDMAPPER_CACHE_MAXSIZE=1000,
|
||||
_MAINTENANCE_COUNT=(3600 * 7) - 1,
|
||||
_LAST_SERVER_TIME_SNAPSHOT=0,
|
||||
ServerConfig=DEFAULT,
|
||||
) as mocks:
|
||||
mocks["connection"].close = MagicMock()
|
||||
|
|
@ -117,6 +120,7 @@ class TestServer(TestCase):
|
|||
connection=DEFAULT,
|
||||
_IDMAPPER_CACHE_MAXSIZE=1000,
|
||||
_MAINTENANCE_COUNT=(3600 * 7) - 1,
|
||||
_LAST_SERVER_TIME_SNAPSHOT=0,
|
||||
SESSIONS=DEFAULT,
|
||||
_IDLE_TIMEOUT=10,
|
||||
time=DEFAULT,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue