Skip to content
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

The nested use of pools #177

Closed
hitriyvalenok opened this issue May 12, 2023 · 1 comment
Closed

The nested use of pools #177

hitriyvalenok opened this issue May 12, 2023 · 1 comment

Comments

@hitriyvalenok
Copy link

hitriyvalenok commented May 12, 2023

Hello there! I am actively using your implementation and it works great! But I ran into an issue with the nested use of ContextWorkerPool. I have two tasks: Main and Sub. I create a pool with Main, Main creates a pool with Sub. The issue is its work looks like an absolute mess.

An example. I've created a pool with workers limited to one and submitted three Main tasks that create one Sub task each. It should be running sequentially, one after another. But the real behavior is: the first thread executed well but then the two remaining start simultaneously! Log of the example:

[2023-05-12 16-22-17.548300] ====== Start ======
[2023-05-12 16-22-17.614900] Main task 'main-1' started
[2023-05-12 16-22-17.669900] Sub task 'main-1 -> sub-1' started
[2023-05-12 16-22-20.670400] Sub task 'main-1 -> sub-1' end
[2023-05-12 16-22-20.671800] Sub task 'main-1 -> sub-1' done
[2023-05-12 16-22-20.671900] Main task 'main-1' end
[2023-05-12 16-22-20.673400] Main task 'main-2' started
[2023-05-12 16-22-20.674500] Main task 'main-3' started
[2023-05-12 16-22-20.717600] Sub task 'main-2 -> sub-1' started
[2023-05-12 16-22-20.717600] Sub task 'main-3 -> sub-1' started
[2023-05-12 16-22-23.718900] Sub task 'main-3 -> sub-1' end
[2023-05-12 16-22-23.718900] Sub task 'main-2 -> sub-1' end
[2023-05-12 16-22-23.719900] Sub task 'main-2 -> sub-1' done
[2023-05-12 16-22-23.720000] Main task 'main-2' end
[2023-05-12 16-22-23.720500] Sub task 'main-3 -> sub-1' done
[2023-05-12 16-22-23.720600] Main task 'main-3' end

As seen from the logs, at 16-22-20, just after main-1 had been done, main-2 and main-3 starts simultaneously! But if I run only one pool (Main or Sub - no matter), it runs ok.

The demo project with the implementation of the example above: project.zip

Thank you!

@trowski
Copy link
Member

trowski commented May 12, 2023

There was an issue with pushing workers both into the idle list and fulfilling a deferred, so potentially two tasks would execute on the same worker simultaneously. The issue has now been fixed. I'll tag a new release soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants