mirror of
https://github.com/evennia/evennia.git
synced 2026-04-03 06:27:17 +02:00
Changed contrib/procpool's PROC_MODIFIED_OBJS list to sit in src.utils.idmapper.base as well as be a WeakValueDictionary instead of a normal list. This removes unnecessary reference counts to objects.
This commit is contained in:
parent
cdc071981d
commit
87d1254b2c
3 changed files with 13 additions and 10 deletions
|
|
@ -25,10 +25,11 @@ _GA = object.__getattribute__
|
|||
_SA = object.__setattr__
|
||||
_DA = object.__delattr__
|
||||
|
||||
|
||||
# determine if our current pid is different from the server PID (i.e.
|
||||
# if we are in a subprocess or not)
|
||||
from src import PROC_MODIFIED_OBJS
|
||||
# if we are in a subprocess or not); Changes are stored here so the
|
||||
# main process can be informed to update itself.
|
||||
PROC_MODIFIED_COUNT = 0
|
||||
PROC_MODIFIED_OBJS = WeakValueDictionary()
|
||||
|
||||
# get info about the current process and thread
|
||||
_SELF_PID = os.getpid()
|
||||
|
|
@ -36,6 +37,8 @@ _SERVER_PID, _PORTAL_PID = get_evennia_pids()
|
|||
_IS_SUBPROCESS = (_SERVER_PID and _PORTAL_PID) and not _SELF_PID in (_SERVER_PID, _PORTAL_PID)
|
||||
_IS_MAIN_THREAD = threading.currentThread().getName() == "MainThread"
|
||||
|
||||
|
||||
|
||||
#_SERVER_PID = None
|
||||
#_PORTAL_PID = None
|
||||
# #global _SERVER_PID, _PORTAL_PID, _IS_SUBPROCESS, _SELF_PID
|
||||
|
|
@ -259,7 +262,9 @@ class SharedMemoryModel(Model):
|
|||
if _IS_SUBPROCESS:
|
||||
# we keep a store of objects modified in subprocesses so
|
||||
# we know to update their caches in the central process
|
||||
PROC_MODIFIED_OBJS.append(cls)
|
||||
global PROC_MODIFIED_COUNT, PROC_MODIFIED_OBJS
|
||||
PROC_MODIFIED_COUNT += 1
|
||||
PROC_MODIFIED_OBJS[PROC_MODIFIED_COUNT] = cls
|
||||
|
||||
if _IS_MAIN_THREAD:
|
||||
# in main thread - normal operation
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue