Change #wait_for_idle to #idle witch receives a block and process it when there is a idle worker. If no block is receive its returns when there is a idle worker.