Easy way to return the first matching value and stop all tasks? #292
-
I'm writing a password bruteforcer using the async gems, and I want to try all combinations of usernames and passwords. I'm using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 12 replies
-
Following code comes from: Can't you just use waiter = Async::Waiter.new(parent: barrier)
Async do
jobs.each do |job|
waiter.async do
# ... process job ...
end
end
# Wait for the first two jobs to complete:
done = waiter.wait(2)
# You may use the barrier to stop the remaining jobs
barrier.stop
end |
Beta Was this translation helpful? Give feedback.
I think I know why the LimitedQueue is not working. Since the tasks have stopped, the queue fills up and the enqueueing blocks. You will have to stop those Async tasks also.
I'm traveling right now. So can't test the assumption.