示例#1
0
文件: lmonbe.py 项目: thaolt/PGDB
 def recvUsrData(self, buf_size):
     """Receive data from the front-end."""
     udata = create_string_buffer(buf_size)
     lmon.call(self.lib.LMON_be_recvUsrData, cast(udata, c_void_p))
     if self.amIMaster():
         return lmon.udata_unserialize(udata.raw)
     return None
示例#2
0
文件: lmonfe.py 项目: alexzah/PGDB
 def getProctable(self, session, maxsize):
     """Return the process table and its size with LMON_fe_getProctable."""
     proctab_type = lmon.MPIR_PROCDESC_EXT * maxsize
     proctab = proctab_type()
     size = c_uint()
     lmon.call(self.lib.LMON_fe_getProctable, session, byref(proctab), byref(size), c_uint(maxsize))
     return proctab, size.value
示例#3
0
    def attachAndSpawnDaemons(self, session, hostname, pid, daemon, d_argv,
                              febe_data, befe_data):
        """Invoke LMON_fe_attachAndSpawnDaemons.

        See the manpages. d_argv is a list.
        befe_data is the size of the desired buffer or None.

        """
        # Need a trailing null entry on the array.
        d_argv += [None]
        _d_argv = lmon.create_array(c_char_p, d_argv)
        if febe_data is not None:
            _febe_data = lmon.udata_serialize(febe_data)
        else:
            _febe_data = cast(None, c_void_p)
        buf = None
        if befe_data is not None:
            buf = create_string_buffer(befe_data)
            _befe_data = cast(buf, c_void_p)
        else:
            _befe_data = cast(None, c_void_p)
        lmon.call(self.lib.LMON_fe_attachAndSpawnDaemons, session, hostname,
                  pid, daemon, _d_argv, _febe_data, _befe_data)
        if befe_data:
            return lmon.udata_unserialize(buf.value)
        else:
            return None
示例#4
0
文件: lmonbe.py 项目: ctanis/PGDB
 def recvUsrData(self, buf_size):
     """Receive data from the front-end."""
     udata = create_string_buffer(buf_size)
     lmon.call(self.lib.LMON_be_recvUsrData, cast(udata, c_void_p))
     if self.amIMaster():
         return lmon.udata_unserialize(udata.raw)
     return None
示例#5
0
文件: lmonfe.py 项目: ctanis/PGDB
    def attachAndSpawnDaemons(self, session, hostname, pid, daemon, d_argv,
                              febe_data, befe_data):
        """Invoke LMON_fe_attachAndSpawnDaemons.

        See the manpages. d_argv is a list.
        befe_data is the size of the desired buffer or None.

        """
        # Need a trailing null entry on the array.
        d_argv += [None]
        _d_argv = lmon.create_array(c_char_p, d_argv)
        if febe_data is not None:
            _febe_data = lmon.udata_serialize(febe_data)
        else:
            _febe_data = cast(None, c_void_p)
        buf = None
        if befe_data is not None:
            buf = create_string_buffer(befe_data)
            _befe_data = cast(buf, c_void_p)
        else:
            _befe_data = cast(None, c_void_p)
        lmon.call(self.lib.LMON_fe_attachAndSpawnDaemons, session, hostname,
                  pid, daemon, _d_argv, _febe_data, _befe_data)
        if befe_data:
            return lmon.udata_unserialize(buf.value)
        else:
            return None
示例#6
0
文件: lmonbe.py 项目: ctanis/PGDB
 def getMyProctab(self, maxsize):
     """Return the process table and size for this process."""
     proctab_type = lmon.MPIR_PROCDESC_EXT * maxsize
     proctab = proctab_type()
     size = c_int()
     lmon.call(self.lib.LMON_be_getMyProctab, byref(proctab), byref(size),
               maxsize)
     return proctab, size.value
示例#7
0
文件: lmonbe.py 项目: thaolt/PGDB
 def getMyProctab(self, maxsize):
     """Return the process table and size for this process."""
     proctab_type = lmon.MPIR_PROCDESC_EXT * maxsize
     proctab = proctab_type()
     size = c_int()
     lmon.call(self.lib.LMON_be_getMyProctab, byref(proctab), byref(size),
               maxsize)
     return proctab, size.value
示例#8
0
 def getProctable(self, session, maxsize):
     """Return the process table and its size."""
     proctab_type = lmon.MPIR_PROCDESC_EXT * maxsize
     proctab = proctab_type()
     size = c_uint()
     lmon.call(self.lib.LMON_fe_getProctable, session, byref(proctab),
               byref(size), c_uint(maxsize))
     return proctab, size.value
示例#9
0
文件: lmonbe.py 项目: ctanis/PGDB
    def handshake(self, udata):
        """Do the LaunchMON handshake.

        If udata is not None, it should be the length of the buffer to
        unserialize front-end data to.

        """
        if udata is None:
            lmon.call(self.lib.LMON_be_handshake, cast(None, c_void_p))
        else:
            buf = create_string_buffer(udata)
            lmon.call(self.lib.LMON_be_handshake, cast(buf, c_void_p))
            # Check if we actually received data.
            if buf.raw[0] != "\0":
                return lmon.udata_unserialize(buf.value)
            return None
示例#10
0
文件: lmonfe.py 项目: alexzah/PGDB
    def putToBeDaemonEnv(self, session, environ):
        """Set up the backend environment with LMON_fe_putToBeDaemonEnv.

        Environ is a list of tuples of keys and values.

        """
        env_list_type = lmon.lmon_daemon_env_t * len(environ)
        env_list = env_list_type()
        for k, env_item in enumerate(environ):
            env_list[k].envName = env_item[0]
            env_list[k].envValue = env_item[1]
            if k < (len(environ) - 1):
                env_list[k].next = pointer(env_list[k + 1])
            else:
                env_list[k].next = None
        lmon.call(self.lib.LMON_fe_putToBeDaemonEnv, session, env_list, len(environ))
示例#11
0
文件: lmonbe.py 项目: thaolt/PGDB
    def handshake(self, udata):
        """Do the LaunchMON handshake.

        If udata is not None, it should be the length of the buffer to
        unserialize front-end data to.

        """
        if udata is None:
            lmon.call(self.lib.LMON_be_handshake, cast(None, c_void_p))
        else:
            buf = create_string_buffer(udata)
            lmon.call(self.lib.LMON_be_handshake, cast(buf, c_void_p))
            # Check if we actually received data.
            if buf.raw[0] != "\0":
                return lmon.udata_unserialize(buf.value)
            return None
示例#12
0
    def putToBeDaemonEnv(self, session, environ):
        """Set up the backend environment with LMON_fe_putToBeDaemonEnv.

        Environ is a list of tuples of keys and values.

        """
        env_list_type = lmon.lmon_daemon_env_t * len(environ)
        env_list = env_list_type()
        for k, env_item in enumerate(environ):
            env_list[k].envName = env_item[0]
            env_list[k].envValue = env_item[1]
            if k < (len(environ) - 1):
                env_list[k].next = pointer(env_list[k + 1])
            else:
                env_list[k].next = None
        lmon.call(self.lib.LMON_fe_putToBeDaemonEnv, session, env_list,
                  len(environ))
示例#13
0
文件: lmonbe.py 项目: thaolt/PGDB
    def init(self, argc, argv):
        """Invoke LMON_be_init.

        argc is the number of arguments in argv.
        argv is a list of arguments to pass as argv.

        """
        _argc = c_int(argc)
        # This is horribly ugly code to properly reconstruct argv for LaunchMON.
        # We stuff the arguments in string buffers (since they can be modified).
        # We stuff those into an array.
        # We add an entry at the end with a bunch of null bytes, since the last
        # argv entry is supposed to be a null and otherwise LaunchMON will make
        # malloc *very* unhappy.
        # We create a pointer to this array.
        # We pass that pointer by reference (another pointer).
        tmp_argv = [cast(create_string_buffer(x), c_char_p) for x in argv]
        tmp_argv.append(cast(create_string_buffer(32), c_char_p))
        _argv = lmon.create_array(c_char_p, tmp_argv)
        argv_ref = c_void_p(addressof(_argv))
        lmon.call(self.lib.LMON_be_init, lmon.LMON_VERSION, byref(_argc),
                  byref(argv_ref))
示例#14
0
文件: lmonbe.py 项目: ctanis/PGDB
    def init(self, argc, argv):
        """Invoke LMON_be_init.

        argc is the number of arguments in argv.
        argv is a list of arguments to pass as argv.

        """
        _argc = c_int(argc)
        # This is horribly ugly code to properly reconstruct argv for LaunchMON.
        # We stuff the arguments in string buffers (since they can be modified).
        # We stuff those into an array.
        # We add an entry at the end with a bunch of null bytes, since the last
        # argv entry is supposed to be a null and otherwise LaunchMON will make
        # malloc *very* unhappy.
        # We create a pointer to this array.
        # We pass that pointer by reference (another pointer).
        tmp_argv = [cast(create_string_buffer(x), c_char_p) for x in argv]
        tmp_argv.append(cast(create_string_buffer(32), c_char_p))
        _argv = lmon.create_array(c_char_p, tmp_argv)
        argv_ref = c_void_p(addressof(_argv))
        lmon.call(self.lib.LMON_be_init, lmon.LMON_VERSION, byref(_argc),
                  byref(argv_ref))
示例#15
0
文件: lmonbe.py 项目: thaolt/PGDB
    def broadcast(self, udata, size):
        """Broadcast data.

        The master provides data and the size of it, and this returns None.
        The slaves can provide None for the data, and size is the size of the
        buffer, which is returned after unserialization.

        """
        if self.amIMaster():
            # Master sends the data, returns None.
            lmon.call(self.lib.LMON_be_broadcast, lmon.udata_serialize(udata),
                      size)
            return None
        else:
            # Slave returns the data.
            buf = create_string_buffer(size)
            lmon.call(self.lib.LMON_be_broadcast, cast(buf, c_void_p), size)
            # Depending on the application, there appears to be a spurious null
            # byte at the start of the data. I do not know why. This avoids it.
            if buf.raw[0] == "\0" and buf.raw[1] != "\0":
                buf = string_at(addressof(buf) + 1)
            else:
                buf = buf.value
            return lmon.udata_unserialize(buf)
示例#16
0
文件: lmonbe.py 项目: thaolt/PGDB
    def scatter(self, udata_array, elem_size):
        """Scatter data.

        The master provides udata_array, which is an array of data to scatter.
        The slaves may provide None for the data.
        elem_size is the size of each element. Due to serialization of data,
        this should be the maximum size of the data, and the elements are padded
        to this length.

        All callers return their respective data (including the master).

        """
        buf = create_string_buffer(elem_size)
        if self.amIMaster():
            # Master pads data if needed and sends.
            total_size = len(udata_array) * elem_size
            send_buf = create_string_buffer(total_size)
            buf_addr = addressof(send_buf)
            idx = 0
            for elem in udata_array:
                tmp_buf = create_string_buffer(
                    string_at(lmon.udata_serialize(elem)), elem_size)
                memmove(buf_addr + (idx * elem_size), tmp_buf, elem_size)
                idx += 1
            lmon.call(self.lib.LMON_be_scatter, cast(send_buf, c_void_p),
                      elem_size, cast(buf, c_void_p))
        else:
            lmon.call(self.lib.LMON_be_scatter, cast(None, c_void_p),
                      elem_size, cast(buf, c_void_p))
        # This is here for the same reason as in broadcast.
        # Note that it appears that the null byte is only present for children.
        if buf.raw[0] == "\0" and buf.raw[1] != "\0":
            buf = string_at(addressof(buf) + 1)
        else:
            buf = buf.value
        return lmon.udata_unserialize(buf)
示例#17
0
文件: lmonbe.py 项目: ctanis/PGDB
    def broadcast(self, udata, size):
        """Broadcast data.

        The master provides data and the size of it, and this returns None.
        The slaves can provide None for the data, and size is the size of the
        buffer, which is returned after unserialization.

        """
        if self.amIMaster():
            # Master sends the data, returns None.
            lmon.call(self.lib.LMON_be_broadcast, lmon.udata_serialize(udata),
                      size)
            return None
        else:
            # Slave returns the data.
            buf = create_string_buffer(size)
            lmon.call(self.lib.LMON_be_broadcast, cast(buf, c_void_p), size)
            # Depending on the application, there appears to be a spurious null
            # byte at the start of the data. I do not know why. This avoids it.
            if buf.raw[0] == "\0" and buf.raw[1] != "\0":
                buf = string_at(addressof(buf) + 1)
            else:
                buf = buf.value
            return lmon.udata_unserialize(buf)
示例#18
0
文件: lmonfe.py 项目: alexzah/PGDB
 def launchAndSpawnDaemons(self, session, hostname, launcher, l_argv, daemon, d_argv, febe_data,
                           befe_data):
     """Invoke LMON_fe_launchAndSpawnDaemons."""
     # Need trailing null entries on the arrays.
     l_argv += [None]
     d_argv += [None]
     _l_argv = lmon.create_array(c_char_p, l_argv)
     _d_argv = lmon.create_array(c_char_p, d_argv)
     if febe_data is not None:
         _febe_data = lmon.udata_serialize(febe_data)
     else:
         _febe_data = cast(None, c_void_p)
     buf = None
     if befe_data is not None:
         buf = create_string_buffer(befe_data)
         _befe_data = cast(buf, c_void_p)
     else:
         _befe_data = cast(None, c_void_p)
     lmon.call(self.lib.LMON_fe_launchAndSpawnDaemons, session, hostname, launcher, _l_argv,
               daemon, _d_argv, _febe_data, _befe_data)
     if befe_data:
         return lmon.udata_unserialize(buf.value)
     else:
         return None
示例#19
0
文件: lmonbe.py 项目: ctanis/PGDB
    def scatter(self, udata_array, elem_size):
        """Scatter data.

        The master provides udata_array, which is an array of data to scatter.
        The slaves may provide None for the data.
        elem_size is the size of each element. Due to serialization of data,
        this should be the maximum size of the data, and the elements are padded
        to this length.

        All callers return their respective data (including the master).

        """
        buf = create_string_buffer(elem_size)
        if self.amIMaster():
            # Master pads data if needed and sends.
            total_size = len(udata_array) * elem_size
            send_buf = create_string_buffer(total_size)
            buf_addr = addressof(send_buf)
            idx = 0
            for elem in udata_array:
                tmp_buf = create_string_buffer(
                    string_at(lmon.udata_serialize(elem)), elem_size)
                memmove(buf_addr + (idx * elem_size), tmp_buf, elem_size)
                idx += 1
            lmon.call(self.lib.LMON_be_scatter, cast(send_buf, c_void_p),
                      elem_size, cast(buf, c_void_p))
        else:
            lmon.call(self.lib.LMON_be_scatter, cast(None, c_void_p), elem_size,
                      cast(buf, c_void_p))
        # This is here for the same reason as in broadcast.
        # Note that it appears that the null byte is only present for children.
        if buf.raw[0] == "\0" and buf.raw[1] != "\0":
            buf = string_at(addressof(buf) + 1)
        else:
            buf = buf.value
        return lmon.udata_unserialize(buf)
示例#20
0
 def launchAndSpawnDaemons(self, session, hostname, launcher, l_argv,
                           daemon, d_argv, febe_data, befe_data):
     """Invoke LMON_fe_launchAndSpawnDaemons."""
     # Need trailing null entries on the arrays.
     l_argv += [None]
     d_argv += [None]
     _l_argv = lmon.create_array(c_char_p, l_argv)
     _d_argv = lmon.create_array(c_char_p, d_argv)
     if febe_data is not None:
         _febe_data = lmon.udata_serialize(febe_data)
     else:
         _febe_data = cast(None, c_void_p)
     buf = None
     if befe_data is not None:
         buf = create_string_buffer(befe_data)
         _befe_data = cast(buf, c_void_p)
     else:
         _befe_data = cast(None, c_void_p)
     lmon.call(self.lib.LMON_fe_launchAndSpawnDaemons, session, hostname,
               launcher, _l_argv, daemon, _d_argv, _febe_data, _befe_data)
     if befe_data:
         return lmon.udata_unserialize(buf.value)
     else:
         return None
示例#21
0
文件: lmonbe.py 项目: ctanis/PGDB
 def sendUsrData(self, udata):
     """Send data to the front-end."""
     lmon.call(self.lib.LMON_be_sendUsrData, lmon.udata_serialize(udata))
示例#22
0
文件: lmonbe.py 项目: ctanis/PGDB
 def regPackForBeToFe(self, callback):
     """Register a pack function."""
     self.pack_cb = self.pack_type(callback)
     lmon.call(self.lib.LMON_be_regPackForBeToFe, self.pack_cb)
示例#23
0
文件: lmonbe.py 项目: thaolt/PGDB
 def amIMaster(self):
     """Return whether this process is the master."""
     rc = lmon.call(self.lib.LMON_be_amIMaster)
     if rc == lmon.LMON_YES:
         return True
     return False
示例#24
0
文件: lmonfe.py 项目: alexzah/PGDB
 def createSession(self):
     """Create and return a session handle with LMON_fe_createSession."""
     session = c_int()
     lmon.call(self.lib.LMON_fe_createSession, byref(session))
     return session.value
示例#25
0
文件: lmonfe.py 项目: alexzah/PGDB
 def kill(self, session):
     """Destroy all resources associated with the session."""
     lmon.call(self.lib.LMON_fe_kill, session)
示例#26
0
文件: lmonfe.py 项目: alexzah/PGDB
 def detach(self, session):
     """Detach from the resource manager but leave daemons running."""
     lmon.call(self.lib.LMON_fe_detach, session)
示例#27
0
文件: lmonfe.py 项目: alexzah/PGDB
 def getProctableSize(self, session):
     """Return the size of the process table with LMON_fe_getProctableSize."""
     size = c_uint()
     lmon.call(self.lib.LMON_fe_getProctableSize, session, byref(size))
     return size.value
示例#28
0
 def init(self):
     """Invoke LMON_fe_init."""
     lmon.call(self.lib.LMON_fe_init, lmon.LMON_VERSION)
示例#29
0
 def kill(self, session):
     """Destroy all resources associated with the session."""
     lmon.call(self.lib.LMON_fe_kill, session)
示例#30
0
 def shutdownDaemons(self, session):
     """Detach from the resource manager and shut down daemons."""
     lmon.call(self.lib.LMON_fe_shutdownDaemons, session)
示例#31
0
 def detach(self, session):
     """Detach from the resource manager but leave daemons running."""
     lmon.call(self.lib.LMON_fe_detach, session)
示例#32
0
文件: lmonbe.py 项目: thaolt/PGDB
 def barrier(self):
     """Make a barrier."""
     lmon.call(self.lib.LMON_be_barrier)
示例#33
0
 def getProctableSize(self, session):
     """Return the size of the process table."""
     size = c_uint()
     lmon.call(self.lib.LMON_fe_getProctableSize, session, byref(size))
     return size.value
示例#34
0
文件: lmonbe.py 项目: ctanis/PGDB
 def barrier(self):
     """Make a barrier."""
     lmon.call(self.lib.LMON_be_barrier)
示例#35
0
 def sendUsrDataBe(self, session, febe_data):
     """Send user data to the backend."""
     lmon.call(self.lib.LMON_fe_sendUsrDataBe, session,
               lmon.udata_serialize(febe_data))
示例#36
0
 def createSession(self):
     """Create and return a session handle with LMON_fe_createSession."""
     session = c_int()
     lmon.call(self.lib.LMON_fe_createSession, byref(session))
     return session.value
示例#37
0
文件: lmonbe.py 项目: thaolt/PGDB
 def regUnpackForFeToBe(self, callback):
     """Register an unpack function."""
     self.unpack_cb = self.unpack_type(callback)
     lmon.call(self.lib.LMON_be_regUnpackForFeToBe, self.unpack_cb)
示例#38
0
文件: lmonbe.py 项目: thaolt/PGDB
 def sendUsrData(self, udata):
     """Send data to the front-end."""
     lmon.call(self.lib.LMON_be_sendUsrData, lmon.udata_serialize(udata))
示例#39
0
文件: lmonfe.py 项目: alexzah/PGDB
 def shutdownDaemons(self, session):
     """Detach from the resource manager and shut down daemons."""
     lmon.call(self.lib.LMON_fe_shutdownDaemons, session)
示例#40
0
文件: lmonbe.py 项目: ctanis/PGDB
 def ready(self, udata):
     """Inform the front-end that we are ready."""
     if udata is None:
         lmon.call(self.lib.LMON_be_ready, cast(None, c_void_p))
     else:
         lmon.call(self.lib.LMON_be_ready, lmon.udata_serialize(udata))
示例#41
0
文件: lmonfe.py 项目: alexzah/PGDB
 def init(self):
     """Invoke LMON_fe_init."""
     lmon.call(self.lib.LMON_fe_init, lmon.LMON_VERSION)
示例#42
0
文件: lmonbe.py 项目: thaolt/PGDB
 def regPackForBeToFe(self, callback):
     """Register a pack function."""
     self.pack_cb = self.pack_type(callback)
     lmon.call(self.lib.LMON_be_regPackForBeToFe, self.pack_cb)
示例#43
0
文件: lmonbe.py 项目: thaolt/PGDB
 def getMyProctabSize(self):
     """Return the size of the process table."""
     size = c_int()
     lmon.call(self.lib.LMON_be_getMyProctabSize, byref(size))
     return size.value
示例#44
0
 def recvUsrDataBe(self, session, buf_size):
     """Receive user data from the backend."""
     befe_data = create_string_buffer(buf_size)
     lmon.call(self.lib.LMON_fe_recvUsrDataBe, session,
               cast(befe_data, c_void_p))
     return lmon.udata_unserialize(befe_data.raw)
示例#45
0
文件: lmonbe.py 项目: ctanis/PGDB
 def getMyProctabSize(self):
     """Return the size of the process table."""
     size = c_int()
     lmon.call(self.lib.LMON_be_getMyProctabSize, byref(size))
     return size.value
示例#46
0
文件: lmonfe.py 项目: alexzah/PGDB
 def regPackForFeToBe(self, session, callback):
     """Register a pack function with LMON_fe_regPackForFeToBe."""
     cb = self.pack_type(callback)
     self.pack_cbs[session] = cb
     lmon.call(self.lib.LMON_fe_regPackForFeToBe, session, cb)
示例#47
0
文件: lmonbe.py 项目: ctanis/PGDB
 def finalize(self):
     """Finalize this session."""
     lmon.call(self.lib.LMON_be_finalize)
示例#48
0
文件: lmonbe.py 项目: ctanis/PGDB
 def getMyRank(self):
     """Return the rank of this process."""
     rank = c_int()
     lmon.call(self.lib.LMON_be_getMyRank, byref(rank))
     return rank.value
示例#49
0
文件: lmonbe.py 项目: ctanis/PGDB
 def regUnpackForFeToBe(self, callback):
     """Register an unpack function."""
     self.unpack_cb = self.unpack_type(callback)
     lmon.call(self.lib.LMON_be_regUnpackForFeToBe, self.unpack_cb)
示例#50
0
文件: lmonbe.py 项目: ctanis/PGDB
 def getSize(self):
     """Return the number of LaunchMON processes."""
     size = c_int()
     lmon.call(self.lib.LMON_be_getSize, byref(size))
     return size.value
示例#51
0
文件: lmonbe.py 项目: thaolt/PGDB
 def finalize(self):
     """Finalize this session."""
     lmon.call(self.lib.LMON_be_finalize)
示例#52
0
 def regPackForFeToBe(self, session, callback):
     """Register a pack function with LMON_fe_regPackForFeToBe."""
     cb = self.pack_type(callback)
     self.pack_cbs[session] = cb
     lmon.call(self.lib.LMON_fe_regPackForFeToBe, session, cb)
示例#53
0
文件: lmonbe.py 项目: thaolt/PGDB
 def getMyRank(self):
     """Return the rank of this process."""
     rank = c_int()
     lmon.call(self.lib.LMON_be_getMyRank, byref(rank))
     return rank.value
示例#54
0
 def regUnpackForBeToFe(self, session, callback):
     """Register an unpack function with LMON_fe_regUnpackForBeToFe."""
     cb = self.unpack_type(callback)
     self.unpack_cbs[session] = cb
     lmon.call(self.lib.LMON_fe_regUnpackForBeToFe, session, cb)
示例#55
0
文件: lmonfe.py 项目: alexzah/PGDB
 def regUnpackForBeToFe(self, session, callback):
     """Register an unpack function with LMON_fe_regUnpackForBeToFe."""
     cb = self.unpack_type(callback)
     self.unpack_cbs[session] = cb
     lmon.call(self.lib.LMON_fe_regUnpackForBeToFe, session, cb)
示例#56
0
文件: lmonbe.py 项目: thaolt/PGDB
 def getSize(self):
     """Return the number of LaunchMON processes."""
     size = c_int()
     lmon.call(self.lib.LMON_be_getSize, byref(size))
     return size.value
示例#57
0
文件: lmonbe.py 项目: ctanis/PGDB
 def amIMaster(self):
     """Return whether this process is the master."""
     rc = lmon.call(self.lib.LMON_be_amIMaster)
     if rc == lmon.LMON_YES:
         return True
     return False
示例#58
0
文件: lmonfe.py 项目: alexzah/PGDB
 def sendUsrDataBe(self, session, febe_data):
     """Send user data to the backend with LMON_fe_sendUsrDataBe (it is serialized)."""
     lmon.call(self.lib.LMON_fe_sendUsrDataBe, session, lmon.udata_serialize(febe_data))
示例#59
0
文件: lmonbe.py 项目: thaolt/PGDB
 def ready(self, udata):
     """Inform the front-end that we are ready."""
     if udata is None:
         lmon.call(self.lib.LMON_be_ready, cast(None, c_void_p))
     else:
         lmon.call(self.lib.LMON_be_ready, lmon.udata_serialize(udata))
示例#60
0
文件: lmonfe.py 项目: alexzah/PGDB
 def recvUsrDataBe(self, session, buf_size):
     """Receive user data from the backend with LMON_fe_recvUsrDataBe (it is unserialized)."""
     befe_data = create_string_buffer(buf_size)
     lmon.call(self.lib.LMON_fe_recvUsrDataBe, session, cast(befe_data, c_void_p))
     return lmon.udata_unserialize(befe_data.raw)