def test_if_pool_exists(): # setup output_q = Queue() pool = ThreadPool(5) input_values = set(range(50)) # run for i in input_values: pool.add_task(simple_handler, output_q, i) # assert output_q.join() all_values = set() while not output_q.empty(): all_values.add(output_q.get()) tools.assert_equals(input_values, all_values)
def run(host, port): Log.info('gdz.log run --begin') address = (host, port) serversock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) serversock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) serversock.bind(address) serversock.listen(SOCKET_BACKLOG_SIZE) Log.info('fastsend started on %s:%s' % (host, port, )) pool = ThreadPool(THREAD_POOL_SIZE) while True: Log.debug('Waiting for connection...') clientsock, addr = serversock.accept() Log.debug('Connected from: %s', addr) pool.add_task(handle_request, clientsock) Log.info('gdz.log run --end')