-
Notifications
You must be signed in to change notification settings - Fork 3k
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
allow failed import of Pool from multiprocessing #8162
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix ``list --outdated`` and ``list --uptodate` on platforms without ``sem_open`` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -213,14 +213,20 @@ def latest_info(dist): | |
# This is done for 2x speed up of requests to pypi.org | ||
# so that "real time" of this function | ||
# is almost equal to "user time" | ||
pool = Pool(DEFAULT_POOLSIZE) | ||
|
||
for dist in pool.imap_unordered(latest_info, packages): | ||
if dist is not None: | ||
yield dist | ||
|
||
pool.close() | ||
pool.join() | ||
try: | ||
pool = Pool(DEFAULT_POOLSIZE) | ||
|
||
for dist in pool.imap_unordered(latest_info, packages): | ||
if dist is not None: | ||
yield dist | ||
|
||
pool.close() | ||
pool.join() | ||
except ImportError: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not an expert of when Python actually imports class
In CPython they wrap importing of module in try except clause. So the except part will never be executed in current implementation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also it might be cleaner to move both for loops in a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I think the ImportError block needs to be put on the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah I was wondering if this reliance on delayed import would be allowed, I'll change it if it's really necessary There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not exactly sure from the original bug report which statement is triggering the Also, should this code have a test? Otherwise there's a (small) risk that the two implementations get out of line. |
||
for dist in packages: | ||
dist = latest_info(dist) | ||
if dist is not None: | ||
yield dist | ||
|
||
def output_package_listing(self, packages, options): | ||
packages = sorted( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment should likely be rewritten.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... or just moved inside the "try" block.