Skip to content

gh-64192: Make imap()/imap_unordered() in multiprocessing.pool actually lazy #136871

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

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

obaltian
Copy link

@obaltian obaltian commented Jul 20, 2025

@python-cla-bot
Copy link

python-cla-bot bot commented Jul 20, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Jul 20, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@obaltian obaltian force-pushed the feature/add-buffersize-to-multiprocessing branch from 3cf40e3 to c1f8081 Compare July 20, 2025 13:09
@bedevere-app
Copy link

bedevere-app bot commented Jul 20, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

Using `threading.Semaphore` makes it easier to cap the number of
concurrently ran tasks. It also makes it possible to remove busy
wait in child thread by waiting for semaphore.

Also I've updated code to use the backpressure pattern - the new
tasks are scheduled as soon as the user consumes the old ones.
@obaltian obaltian force-pushed the feature/add-buffersize-to-multiprocessing branch from c1f8081 to ec37be8 Compare July 20, 2025 13:16
@bedevere-app
Copy link

bedevere-app bot commented Jul 20, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@picnixz
Copy link
Member

picnixz commented Jul 20, 2025

Please open an issue first for this one (I don't know if it's something that is discussed in the sprint).

@picnixz
Copy link
Member

picnixz commented Jul 20, 2025

Previous discussion for executor: #74028

@obaltian
Copy link
Author

@picnixz thanks. The issue already exists, I will add more detailed description here soon, just wanted to run all tests for now.

@obaltian
Copy link
Author

@picnixz here is a related issue - #64192, I've left a summary at the end of that thread. Thank you.

@picnixz picnixz changed the title Make imap()/imap_unordered() in multiprocessing.Pool actually lazy gh-64192: Make imap()/imap_unordered() in multiprocessing.Pool actually lazy Jul 20, 2025
@picnixz
Copy link
Member

picnixz commented Jul 20, 2025

Thanks! I'm actually adding the GH issue inthe title so that we can backref it easily.

@picnixz
Copy link
Member

picnixz commented Jul 20, 2025

I'm adding a skipnews just for the CI otherwise you'll get a notification saying that the labels are incorrect.

@obaltian obaltian changed the title gh-64192: Make imap()/imap_unordered() in multiprocessing.Pool actually lazy gh-64192: Make imap()/imap_unordered() in multiprocessing.pool actually lazy Jul 20, 2025
@obaltian obaltian force-pushed the feature/add-buffersize-to-multiprocessing branch from 9114142 to 5b8db62 Compare July 21, 2025 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants