Skip to content

bpo-42363: enhance _check_running() ValueError output in Pool class #23299

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jimlinntu
Copy link

@jimlinntu jimlinntu commented Nov 15, 2020

The current ValueError does not give any information about self._state.
So I think it will be good to output: self._state for the ease of debugging.

https://bugs.python.org/issue42363

@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA).

CLA Missing

Our records indicate the following people have not signed the CLA:

@jimlinntu

For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

If you have recently signed the CLA, please wait at least one business day
before our records are updated.

You can check yourself to see if the CLA has been received.

Thanks again for the contribution, we look forward to reviewing it!

@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Dec 18, 2020
Copy link
Contributor

@MaxwellDupre MaxwellDupre left a comment

Choose a reason for hiding this comment

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

Tests pass ok.
However the output could be better:
File "/home/me/Documents/cpython/Lib/multiprocessing/pool.py", line 350, in _check_running
raise ValueError("Pool not running because self._state is {}".format(self._state))
ValueError: Pool not running because self._state is CLOSE

Please change above line to read:
ValueError: Pool not running because the state is CLOSE

@@ -347,7 +347,7 @@ def _setup_queues(self):

def _check_running(self):
if self._state != RUN:
raise ValueError("Pool not running")
raise ValueError("Pool not running because self._state is {}".format(self._state))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
raise ValueError("Pool not running because self._state is {}".format(self._state))
raise ValueError(f"Pool not running, state is {self._state}")

Copy link
Author

Choose a reason for hiding this comment

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

Will do

Copy link
Author

Choose a reason for hiding this comment

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

Done! Pls check it out

@iritkatriel iritkatriel requested a review from vstinner June 26, 2022 22:07
@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label Jul 31, 2022
Signed-off-by: Jim Lin <b04705003@ntu.edu.tw>
@bedevere-bot
Copy link

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

@jimlinntu
Copy link
Author

I just added it. Never use that before so please check that for me.

@@ -0,0 +1 @@
enhance _check_running() ValuError error message
Copy link
Contributor

Choose a reason for hiding this comment

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

Add state the _check_running() error message.

Suggested change
enhance _check_running() ValuError error message
Add state to the error message of the :meth:`multiprocessing.Pool._check_running` method in the :mod:`multiprocessing` module.

Copy link
Member

Choose a reason for hiding this comment

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

The NEWS entry doesn't mention the module name (multiprocessing) and should not reference a private function (users don't see it). Honestly, I think that you should just remove the NEWS entry. Enhancing an error message is nice, but doesn't require to be documented in the Changelog.

@arhadthedev arhadthedev changed the title bpo-42363: enhance _check_running() ValuError output in Pool class bpo-42363: enhance _check_running() ValueError output in Pool class May 11, 2023
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.

8 participants