-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pool#join not working ? #6
Comments
Yeah, that solution is unacceptable, I know about the issue on MRI, it's a bug in the deadlock inference, I opened a bug on Ruby's issue tracker but I was unable to come up with a reduced testcase, so they ignored it. I'll try to find a proper solution, but it really isn't easy, pools are supposed to be used in long running applications rather than to achieve parallelization in simple scripts. |
No wait, now that I think of it, you should use I think I should make |
The wait for all the tasks to be consumed is actually what I wanted to achieve. I have a batches of workload that comes in at irregular times. Each batch should be handled in different stages. I need to be sure that a batch has finished stage 1 completely before I start with stage 2. Then stage 3 and so on. When the batch is completely processed, it will wait for the next batch. I want to use the same Pool for stage 1, stage 2, stage 3, .... which is why I cannot call shutdown. Actually, I wanted to have 4 threads minimum with a max of up to 20 threads, but - of course - any minimum not 0 does not work with join. I'm actually wondering what the join method is supposed to do, currently? AFAIK it will just hang. I replaced worker.join with a simple sleep(0.3) and trim and that works just as well. worker.join seems to never return. |
So yes, it's kind of useless and not what you want as is. I think the best way to go is to merge the current Depending on how you implement the waiting, having |
OK. I'll have a go. I'll let you know when I'm done. |
BTW. Do you agree that the @trim_requests -= 1 is a bug? Or am I mistaken? |
You're mistaken, the number of trim requests is decreased when one of the workers is closed, if you increment it all the workers will die. |
Are you sure? I was talking about the line in the #trim method. Shouldn't the trim_requests go up when a new trim request is made? |
Auto_trim did not work for me unless I changed that line to += ... |
Oh, yeah, I'm sorry, you're right, I was looking in the worker instead of |
Hi,
Isn't the following supposed to work:
With MRI 2.0 I get:
With JRuby 1.7.4, it hangs. I added some prints where Threads are created and closed and I noticed that threads are only created, never closed.
I found one line, which contains a bug, I think. In Pool#trim I replaced
with
and that helped, but unfortunately only partially. In JRuby I now see that 4 threads are created and 3 of them are closed.
As I was hacking my way aound the code, I also modified Pool#join into:
and that works. I know it defeats your initial purpose of not consuming CPU during waits, so I'd love to get rid of the join timeout, but I cannot see how.
The text was updated successfully, but these errors were encountered: