Example #1
0
def _main():
    thread_count = API.thread_count()
    assert thread_count >= 1

    threads = [_Task(API(thread_index))
               for thread_index in range(thread_count)]
    for thread in threads:
        thread.start()
    for thread in threads:
        thread.join()
Example #2
0
def _main():
    thread_count = API.thread_count()
    assert thread_count >= 1

    threads = [Task(API(thread_index), 'python_c', TerminateException)
               for thread_index in range(thread_count)]
    for thread in threads:
        thread.start()
    for thread in threads:
        thread.join()
Example #3
0
def _main():
    thread_count = API.thread_count()
    assert thread_count >= 1

    threads = [_Task(API(thread_index))
               for thread_index in range(thread_count)]
    for thread in threads:
        thread.start()
    for thread in threads:
        thread.join()
Example #4
0
def _main():
    thread_count = API.thread_count()
    assert thread_count >= 1

    threads = [Task(API(thread_index), 'python_c', TerminateException)
               for thread_index in range(thread_count)]
    for thread in threads:
        thread.start()
    for thread in threads:
        thread.join()
Example #5
0
            self.__check_environment()
            # idle service with no subscriptions
            result = self.__api.poll()
            assert result == False
        except terminate_exception:
            pass
        except:
            traceback.print_exc(file=sys.stderr)
        print('terminate environment python_c')

    def __check_environment(self):
        user = os.environ.get('USER')
        assert user is not None
        assert os.environ[user] == 'user'
        assert os.environ[user + '_' + user] == 'user_user'
        assert os.environ[user + user] == 'useruser'
        assert os.environ[user + '123' + user] == 'user123user'
        assert os.environ['USER_D'] == 'user_$'
        assert os.environ['USER_'] == 'user_'


if __name__ == '__main__':
    thread_count = API.thread_count()
    assert thread_count >= 1

    threads = [Task(API(i)) for i in range(thread_count)]
    for t in threads:
        t.start()
    for t in threads:
        t.join()
Example #6
0
        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)

if __name__ == '__main__':
    thread_count = API.thread_count()
    assert thread_count >= 1
    
    threads = [_Task(i) for i in range(thread_count)]
    for t in threads:
        t.start()
    for t in threads:
        t.join()