Skip to content

bpo-29235: Make cProfile.Profile a context manager. #6808

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

Conversation

ssanderson
Copy link

@ssanderson ssanderson commented May 14, 2018

Add __enter__ and __exit__ methods to cProfile.Profile that call
enable() and disable(), respectively.

https://bugs.python.org/issue29235

@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 your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

When your account is ready, please add a comment in this pull request
and a Python core developer will remove the CLA not signed label
to make the bot check again.

Thanks again to your contribution and we look forward to looking at it!

@ssanderson
Copy link
Author

I believe I've signed the CLA now.

@matrixise
Copy link
Member

@ssanderson thanks for the CLA but the validation is manual. we have to wait for the notification in the bug tracker :/ sorry, maybe @brettcannon could remove the CLA not signed, but you need to prove it. thanks again for your PR.

@ssanderson
Copy link
Author

Ah, I see, I missed the note in the devguide saying to wait a day. Thanks for the heads up @matrixise!

@tiran
Copy link
Member

tiran commented May 14, 2018

@ssanderson Thanks for you PR.

The changeset is missing a news entry. Please follow https://devguide.python.org/committing/#what-s-new-and-news-entries and add a blurb.

@ssanderson
Copy link
Author

@tiran updated with a news entry!

Add `__enter__` and `__exit__` methods to `cProfile.Profiler` that call
`enable()` and `disable()`, respectively.
@ssanderson ssanderson force-pushed the make-profiler-a-contextmanager branch from bde4930 to e4263ae Compare May 14, 2018 19:08
@ssanderson
Copy link
Author

The travis failure here is in test.test_multiprocessing_forkserver.TestIgnoreEINTR. Naively, that seems unlikely to be related to this change?

ERROR: test_ignore (test.test_multiprocessing_forkserver.TestIgnoreEINTR)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/python/cpython/Lib/test/_test_multiprocessing.py", line 4359, in test_ignore
    os.kill(p.pid, signal.SIGUSR1)
ProcessLookupError: [Errno 3] No such process

@brettcannon
Copy link
Member

The PR looks great, so I've just kicked off Travis again just to be safe/paranoid about the failure (but even if it fails again, @ssanderson , just ping this PR once Travis is finished so we don't forget to merge).

@ssanderson
Copy link
Author

@brettcannon looks like travis is happy now.

@ssanderson
Copy link
Author

(I noticed a small typo in the NEWS entry when looking at this again though).

@brettcannon brettcannon self-assigned this May 15, 2018
@ssanderson
Copy link
Author

I think this is good to merge. Anything else that's needed from me here?

@brettcannon brettcannon merged commit 2e01b75 into python:master Jun 1, 2018
@brettcannon
Copy link
Member

Thanks for the patch, @ssanderson ! (And sorry for the delayed response; PyCon US recovery 😉 )

@ssanderson
Copy link
Author

@brettcannon thanks for merging!

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.

7 participants