Exemplo n.º 1
0
 def save(cls, *args, **kwargs):
     "overload spot for saving"
     global _SERVER_PID, _PORTAL_PID, _IS_SUBPROCESS, _SELF_PID
     if not _SERVER_PID and not _PORTAL_PID:
         _SERVER_PID, _PORTAL_PID = _get_pids()
         _IS_SUBPROCESS = (_SERVER_PID and _PORTAL_PID) and (_SERVER_PID != _SELF_PID) and (_PORTAL_PID != _SELF_PID)
     if _IS_SUBPROCESS:
         #print "storing in PROC_MODIFIED_OBJS:", cls.db_key, cls.id
         PROC_MODIFIED_OBJS.append(cls)
     super(SharedMemoryModel, cls).save(*args, **kwargs)
Exemplo n.º 2
0
    def save(cls, *args, **kwargs):
        "save method tracking process/thread issues"

        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)

        if _IS_MAIN_THREAD:
            # in main thread - normal operation
            super(SharedMemoryModel, cls).save(*args, **kwargs)
        else:
            # in another thread; make sure to save in reactor thread
            def _save_callback(cls, *args, **kwargs):
                super(SharedMemoryModel, cls).save(*args, **kwargs)
            #blockingCallFromThread(reactor, _save_callback, cls, *args, **kwargs)
            callFromThread(_save_callback, cls, *args, **kwargs)