mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
bpo-29235: Make cProfile.Profile a context manager (GH-6808)
This commit is contained in:
parent
252f6abe0a
commit
2e01b75884
4 changed files with 52 additions and 0 deletions
|
@ -110,6 +110,13 @@ class Profile(_lsprof.Profiler):
|
|||
finally:
|
||||
self.disable()
|
||||
|
||||
def __enter__(self):
|
||||
self.enable()
|
||||
return self
|
||||
|
||||
def __exit__(self, *exc_info):
|
||||
self.disable()
|
||||
|
||||
# ____________________________________________________________
|
||||
|
||||
def label(code):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue