def test_unique_connections(self): pool = self.get_pool() epool = eventlet.GreenPool() for i in xrange(self.NUM_ITER): epool.spawn_n(self.spawn_slow_network_and_query_slow_response, pool, self.SLOW_NETWORK_QUERY, 1, {'value': i, i: 'value'}) epool.waitall()
def test_start_many_slow_connections(self): """ Test starting many slow connections """ pile = eventlet.GreenPile() [pile.spawn(self.get_connection) for _ in xrange(self.NUM_ITER)] for conn in pile: self.assertIsInstance(conn, RexProEventletConnection)
def test_start_many_connections(self): """ Test starting up many connections """ gevent.joinall([ gevent.spawn(self.get_connection) for _ in xrange(self.NUM_ITER) ], timeout=3)
def test_start_many_slow_connections(self): """ Test starting many slow connections """ gevent.joinall([ gevent.spawn(slow_start_simulation, self) for _ in xrange(self.NUM_ITER) ], timeout=3)
def test_unique_connections(self): pool = self.get_pool() threads = [] for i in xrange(self.NUM_ITER): threads.append( gevent.spawn(self.spawn_slow_network_and_query_slow_response, pool, self.SLOW_NETWORK_QUERY, 1, {'value': i, i: 'value'}) ) gevent.joinall(threads, timeout=5)
def test_many_network_calls(self): """ Test known responses on a network that should be slow, we should get them all asynchronously """ threads = [] for i in xrange(self.NUM_ITER): threads.append( gevent.spawn(spawn_slow_network_and_query_slow_response, self, self.SLOW_NETWORK_QUERY, 1, { 'value': i, i: 'value' })) gevent.joinall(threads, timeout=5)
def test_many_network_calls(self): """ Test known responses on a network that should be slow, we should get them all asynchronously """ pile = eventlet.GreenPile() for i in xrange(self.NUM_ITER): pile.spawn(spawn_slow_network_and_query_slow_response, self, self.SLOW_NETWORK_QUERY, 1, { 'value': i, i: 'value' }) for result in pile: print_(result) self.assertIsInstance(result, dict)
def test_many_network_calls(self): """ Test known responses on a network that should be slow, we should get them all asynchronously """ threads = [] for i in xrange(self.NUM_ITER): threads.append(gevent.spawn(spawn_slow_network_and_query_slow_response, self, self.SLOW_NETWORK_QUERY, 1, {'value': i, i: 'value'} ) ) gevent.joinall(threads, timeout=5)
def test_many_network_calls(self): """ Test known responses on a network that should be slow, we should get them all asynchronously """ pile = eventlet.GreenPile() for i in xrange(self.NUM_ITER): pile.spawn(spawn_slow_network_and_query_slow_response, self, self.SLOW_NETWORK_QUERY, 1, {'value': i, i: 'value'} ) for result in pile: print_(result) self.assertIsInstance(result, dict)
def test_many_concurrent_connections(self): pool = self.get_pool() epool = eventlet.GreenPool() for _ in xrange(self.NUM_ITER): epool.spawn_n(pool.create_connection) epool.waitall()
def test_many_concurrent_connections(self): pool = self.get_pool() gevent.joinall([ gevent.spawn(pool.create_connection) for _ in xrange(self.NUM_ITER) ])
def test_many_concurrent_connections(self): pool = self.get_pool() pile = eventlet.GreenPile() [pile.spawn(pool.create_connection) for _ in xrange(self.NUM_ITER)]
def test_start_many_slow_connections(self): """ Test starting many slow connections """ gevent.joinall([gevent.spawn(slow_start_simulation, self) for _ in xrange(self.NUM_ITER)], timeout=3)
def test_start_many_connections(self): """ Test starting up many connections """ gevent.joinall([gevent.spawn(self.get_connection) for _ in xrange(self.NUM_ITER)], timeout=3)
if __name__ == '__main__': import tasks from rexpro._compat import print_, xrange print_("Queuing up tasks...") SLOW_NETWORK_QUERY = """def test_slow_query(sleep_time, value) { sleep sleep_time return value } return test_slow_query(sleep_length, data) """ NUM_QUERIES = 10000 SLEEP_TIME = 1 script_params_pairs = [(SLOW_NETWORK_QUERY, {'sleep_length': SLEEP_TIME, 'data': i}) for i in xrange(NUM_QUERIES)] results = tasks.start_massive_queries(script_params_pairs) print_("Got Results:") print_(results) else: print_("This must be executed manually")