Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-133485: Use interpreters.Interpreter in InterpreterPoolExecutor#133957

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

ericsnowcurrently
Copy link
Member

@ericsnowcurrentlyericsnowcurrently commentedMay 13, 2025
edited
Loading

Most importantly, this resolves the issues with functions and types defined in__main__.
It also expands the number of supported objects.

@ericsnowcurrentlyericsnowcurrentlyforce-pushed theinterp-pool-executor-use-interp-call branch from5340a57 to62d7c2cCompareMay 13, 2025 01:13
@ericsnowcurrentlyericsnowcurrently marked this pull request as draftMay 13, 2025 01:14
@ericsnowcurrentlyericsnowcurrentlyforce-pushed theinterp-pool-executor-use-interp-call branch 9 times, most recently fromb3c2477 to7697c11CompareMay 27, 2025 16:31
Comment on lines +23 to +26
# InterpreterPoolInitializerTest.test_initializer fails
# if we don't have a LOAD_GLOBAL. (It could be any global.)
# We will address this separately.
INITIALIZER_STATUS
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@markshannon, any ideas on why this is happening? It smells like a ceval bug, but it certainly could be something I've done wrong.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Copy link
Contributor

@neoneneneoneneJun 1, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

There seem to be related changes ininspect.getclosurevars() since83ba8c2:

before:ClosureVars(nonlocals={},globals={'INITIALIZER_STATUS':'uninitialized'},builtins={},unbound=set())after:ClosureVars(nonlocals={},globals={},builtins={},unbound=set())
  • init() on main (without L26):
3RESUME05LOAD_FAST_BORROW0 (x)STORE_GLOBAL0 (INITIALIZER_STATUS)LOAD_CONST0 (None)RETURN_VALUE
  • 3.3.5 (2014):
50LOAD_FAST0 (x)3STORE_GLOBAL0 (INITIALIZER_STATUS)6LOAD_CONST0 (None)9RETURN_VALUE

@ericsnowcurrentlyericsnowcurrentlyforce-pushed theinterp-pool-executor-use-interp-call branch from5ea2bb2 to14a8eb9CompareMay 29, 2025 21:02
@ericsnowcurrentlyericsnowcurrentlyforce-pushed theinterp-pool-executor-use-interp-call branch from14a8eb9 toccc135cCompareMay 30, 2025 15:27
@ericsnowcurrentlyericsnowcurrently marked this pull request as ready for reviewMay 30, 2025 21:32
@ericsnowcurrentlyericsnowcurrently added the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelMay 30, 2025
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@ericsnowcurrently for commitccc135c 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F133957%2Fmerge

If you want to schedule another build, you need to add the🔨 test-with-buildbots label again.

@bedevere-botbedevere-bot removed the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelMay 30, 2025
@neonene
Copy link
Contributor

Thewasm32-wasi Non-Debug buildbot seems to be unused on merged commits and out of order on PRs. For example:https://buildbot.python.org/#/builders/1373/builds/507

ericsnowcurrently reacted with thumbs up emoji

@neonene
Copy link
Contributor

neonene commentedJun 1, 2025
edited
Loading

Is the following usage invalid?

INITIALIZER_STATUS='uninitialized'definit(x):globalINITIALIZER_STATUSINITIALIZER_STATUS=xINITIALIZER_STATUS# for nowdefget_init_status():returnINITIALIZER_STATUSif__name__=="__main__":fromconcurrent.futuresimportInterpreterPoolExecutorexe=InterpreterPoolExecutor(initializer=init,initargs=('initialized',))fut=exe.submit(get_init_status)assertfut.result()=='initialized'# failsexe.shutdown(wait=True)assertINITIALIZER_STATUS=='uninitialized'

@neonene
Copy link
Contributor

neonene commentedJun 3, 2025
edited
Loading

res.loaded=runpy_run_path(filename,run_modname);

I guess the failure case in my previous comment can be resolved if therunpy_run_path is called only once for__main__ by using/keepingctx->main.cached->loaded or something across xi-sessions without being replaced. (My experiment was just putting a static local PyObject* var here ignoring the leak.)

@ericsnowcurrentlyericsnowcurrently changed the titlegh-133485: Use _interpreters.call() in InterpreterPoolExecutorgh-133485: Use interpreters.Interpreters in InterpreterPoolExecutorJun 16, 2025
@ericsnowcurrentlyericsnowcurrently changed the titlegh-133485: Use interpreters.Interpreters in InterpreterPoolExecutorgh-133485: Use interpreters.Interpreter in InterpreterPoolExecutorJun 16, 2025

numtasks = 10
futures = []
executor = self.executor_type()
Copy link
Contributor

@neoneneneoneneJun 17, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

self.executor_type(max_workers=numtasks) or some better way not to get stuck?

@ericsnowcurrently
Copy link
MemberAuthor

FWIW, I haven't been able to reproduce the failures locally. It certainly is consistent across all the CI workers though.

@ericsnowcurrentlyericsnowcurrentlyforce-pushed theinterp-pool-executor-use-interp-call branch fromdafd5a6 to9a8dcddCompareJune 17, 2025 19:55
@ericsnowcurrentlyericsnowcurrentlyforce-pushed theinterp-pool-executor-use-interp-call branch frombb8506b to605c802CompareJune 17, 2025 20:20
@ericsnowcurrentlyericsnowcurrentlyforce-pushed theinterp-pool-executor-use-interp-call branch from32a8752 tocce4c75CompareJune 17, 2025 23:56
@ericsnowcurrently
Copy link
MemberAuthor

Well, I figured out the problem. ApparentlyThreadPoolExecutor only starts new workers if there aren't any idle ones (and max_workers hasn't been reached), which is normally reasonable.

However, when a task is submitted, there's a narrow window from the time the task is queued up to when a worker picks up the job. If a second task is submitted and the code reachesThreadPoolExecutor._adjust_thread_count() before the worker created for the first task picks it up then a second worker will not be started in response to the secondsubmit() call.

The new test (test_blocking), which was hanging, was written with the assumption that there would be one worker for each task. This lead to an effective deadlock when there were fewer workers started. Asnoted by@neonene, the same situation was reachable by restricting the number of workers.

The solution was to unblock the tasks that did get picked up by workers, so they could finish and the workers could pick up the remaining queued tasks.

neonene reacted with thumbs up emoji

@ericsnowcurrentlyericsnowcurrently merged commit725da50 intopython:mainJun 18, 2025
39 checks passed
@miss-islington-app
Copy link

Thanks@ericsnowcurrently for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@ericsnowcurrentlyericsnowcurrently deleted the interp-pool-executor-use-interp-call branchJune 18, 2025 23:57
miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestJun 18, 2025
…tor (pythongh-133957)Most importantly, this resolves the issues with functions and types defined in __main__.It also expands the number of supported objects and simplifies the implementation.(cherry picked from commit725da50)Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
@bedevere-app
Copy link

GH-135695 is a backport of this pull request to the3.14 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.14bugs and security fixes labelJun 18, 2025
ericsnowcurrently added a commit that referenced this pull requestJun 19, 2025
…utor (gh-135695)Most importantly, this resolves the issues with functions and types defined in __main__.It also expands the number of supported objects and simplifies the implementation.(cherry picked from commit725da50, AKAgh-133957)Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
lkollar pushed a commit to lkollar/cpython that referenced this pull requestJun 19, 2025
…tor (pythongh-133957)Most importantly, this resolves the issues with functions and types defined in __main__.It also expands the number of supported objects and simplifies the implementation.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@neoneneneoneneneonene left review comments

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@ericsnowcurrently@bedevere-bot@neonene@AA-Turner

[8]ページ先頭

©2009-2025 Movatter.jp