Skip to content

bpo-29877: compileall: import ProcessPoolExecutor only when needed #4856

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

Merged
merged 6 commits into from
Nov 23, 2018

Conversation

virtuald
Copy link
Contributor

@virtuald virtuald commented Dec 14, 2017

Importing ProcessPoolExecutor may hang or cause an error when the import
accesses urandom on a low resource platform

https://bugs.python.org/issue29877

@the-knights-who-say-ni

This comment has been minimized.

@JulienPalard JulienPalard changed the title bpc-29877: compileall: import ProcessPoolExecutor only when needed bpo-29877: compileall: import ProcessPoolExecutor only when needed Dec 14, 2017
@JulienPalard
Copy link
Member

Hi, thanks for your contribution and welcome!

Can't this be simplified by complexity removing the global and removing the as PPE?

@virtuald
Copy link
Contributor Author

@JulienPalard @methane if you remove the global, the import will happen for each file that is compiled. I know the second import isn't as expensive as the first import, but I'm not really sure how much overhead it would be.

If you're fine with an reimport per-file, then I can change it and this will be much less complex.

Importing ProcessPoolExecutor may hang or cause an error when the import
accesses urandom on a low resource platform
@virtuald
Copy link
Contributor Author

Something wrong with the tests, I'll look at it later.

@virtuald
Copy link
Contributor Author

Fixed the tests, and other improvements as suggested.

@methane
Copy link
Member

methane commented Dec 19, 2017

I know the second import isn't as expensive as the first import, but I'm not really sure how much overhead it would be.

It's negligible compared to compiling Python source.

@methane
Copy link
Member

methane commented Dec 19, 2017

if you remove the global, the import will happen for each file that is compiled.

really? I thought compile_dir is called only once.

@virtuald
Copy link
Contributor Author

Oops, this dropped off my radar. Still an issue though. :)

Updated to simplify as asked. Maybe needs a rebase?

@methane
Copy link
Member

methane commented Nov 23, 2018

We recommend "merge master" than "rebase". We use "Squash and merge" when merging PRs.
So merge commit of "merge master" is not problem to us. And rebase hides "what is changed after last code review".

CIs are failing. It likely because some tests for compilall are added. You need to merge master
and fix them.

@virtuald
Copy link
Contributor Author

virtuald commented Nov 23, 2018

Yeah, I had just noticed that. I fixed the tests (had broken the ability to run unlimited workers with max_workers=0.. oops!), but haven't merged in master yet.

I was running the tests locally by executing the test file directly (since it has a main) -- it seems that a6b3ec5 broke the ability to do that by adding a relative import to the file. If the tests pass on travis I'll merge in master and see what happens.

@virtuald
Copy link
Contributor Author

Looks like it's all working finally.

@miss-islington miss-islington merged commit 1d817e4 into python:master Nov 23, 2018
@miss-islington
Copy link
Contributor

Thanks @virtuald for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6, 3.7.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 23, 2018
…ythonGH-4856)

Importing ProcessPoolExecutor may hang or cause an error when the import
accesses urandom on a low resource platform

https://bugs.python.org/issue29877
(cherry picked from commit 1d817e4)

Co-authored-by: Dustin Spicuzza <dustin@virtualroadside.com>
@bedevere-bot
Copy link

GH-10686 is a backport of this pull request to the 3.7 branch.

@bedevere-bot
Copy link

GH-10687 is a backport of this pull request to the 3.6 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 23, 2018
…ythonGH-4856)

Importing ProcessPoolExecutor may hang or cause an error when the import
accesses urandom on a low resource platform

https://bugs.python.org/issue29877
(cherry picked from commit 1d817e4)

Co-authored-by: Dustin Spicuzza <dustin@virtualroadside.com>
miss-islington added a commit that referenced this pull request Nov 23, 2018
…H-4856)

Importing ProcessPoolExecutor may hang or cause an error when the import
accesses urandom on a low resource platform

https://bugs.python.org/issue29877
(cherry picked from commit 1d817e4)

Co-authored-by: Dustin Spicuzza <dustin@virtualroadside.com>
miss-islington added a commit that referenced this pull request Nov 23, 2018
…H-4856)

Importing ProcessPoolExecutor may hang or cause an error when the import
accesses urandom on a low resource platform

https://bugs.python.org/issue29877
(cherry picked from commit 1d817e4)

Co-authored-by: Dustin Spicuzza <dustin@virtualroadside.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants