Exemple #1
0
class _Task(threading.Thread):
    def __init__(self, thread_index):
        threading.Thread.__init__(self)
        self.__api = API(thread_index)

    def run(self):
        try:
            self.__api.subscribe('python_c', self.request)

            result = self.__api.poll()
            assert result == False
        except terminate_exception:
            pass
        except:
            traceback.print_exc(file=sys.stderr)
        print('terminate msg_size python_c')

    def request(self, command, name, pattern, request_info, request,
                timeout, priority, trans_id, pid):
        i = struct.unpack('=I', request[:4])[0]
        if i == 4294967295:
            i = 0
        else:
            i += 1
        request = struct.pack('=I', i) + request[4:]
        print('forward #%d python_c to %s (with timeout %d ms)' % (
            i, _DESTINATION, timeout,
        ))
        self.__api.forward_(command, _DESTINATION, request_info, request,
                            timeout, priority, trans_id, pid)
Exemple #2
0
class _Task(threading.Thread):
    def __init__(self, thread_index):
        threading.Thread.__init__(self)
        self.__api = API(thread_index)

    def run(self):
        self.__api.subscribe('python_c', self.request)

        result = self.__api.poll()
        print 'exited thread:', result

    def request(self, command, name, pattern, request_info, request, timeout,
                priority, trans_id, pid):
        i = struct.unpack('=I', request[:4])[0]
        if i == 4294967295:
            i = 0
        else:
            i += 1
        request = struct.pack('=I', i) + request[4:]
        print 'forward #%d python_c to %s (with timeout %d ms)' % (
            i,
            _DESTINATION,
            timeout,
        )
        self.__api.forward_(command, _DESTINATION, request_info, request,
                            timeout, priority, trans_id, pid)
Exemple #3
0
class _Task(threading.Thread):
    def __init__(self, thread_index):
        threading.Thread.__init__(self)
        self.__api = API(thread_index)

    def run(self):
        try:
            self.__api.subscribe('python_c', self.request)

            result = self.__api.poll()
            assert result == False
        except terminate_exception:
            pass
        except:
            traceback.print_exc(file=sys.stderr)
        print('terminate msg_size python_c')

    def request(self, request_type, name, pattern, request_info, request,
                timeout, priority, trans_id, pid):
        i = struct.unpack('=I', request[:4])[0]
        if i == 4294967295:
            i = 0
        else:
            i += 1
        request = struct.pack('=I', i) + request[4:]
        print('forward #%d python_c to %s (with timeout %d ms)' % (
            i, _DESTINATION, timeout,
        ))
        self.__api.forward_(request_type, _DESTINATION, request_info, request,
                            timeout, priority, trans_id, pid)
Exemple #4
0
class _Task(threading.Thread):
    def __init__(self, thread_index):
        threading.Thread.__init__(self)
        self.__api = API(thread_index)

    def run(self):
        self.__api.subscribe("python_c", self.request)

        result = self.__api.poll()
        print "exited thread:", result

    def request(self, command, name, pattern, request_info, request, timeout, priority, trans_id, pid):
        i = struct.unpack("=I", request[:4])[0]
        if i == 4294967295:
            i = 0
        else:
            i += 1
        request = struct.pack("=I", i) + request[4:]
        print "forward #%d python_c to %s (with timeout %d ms)" % (i, _DESTINATION, timeout)
        self.__api.forward_(command, _DESTINATION, request_info, request, timeout, priority, trans_id, pid)