Skip to content

Commit

Permalink
Unregister callbacks in doctests (#8276)
Browse files Browse the repository at this point in the history
Some of our callback doctests weren't calling `unregister()` which lead to `Callback.active` being unexpectedly populated when running both unit tests and doctests at the same time. This PR adds `unregister()` calls accordingly.
  • Loading branch information
jrbourbeau committed Oct 20, 2021
1 parent 38fbcf1 commit 5b63301
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dask/diagnostics/profile.py
Expand Up @@ -51,6 +51,7 @@ class Profiler(Callback):
manually.
>>> prof.clear()
>>> prof.unregister()
"""

Expand Down Expand Up @@ -140,6 +141,8 @@ class ResourceProfiler(Callback):
Note that when used as a context manager data will be collected throughout
the duration of the enclosed block. In contrast, when registered globally
data will only be collected while a dask scheduler is active.
>>> prof.unregister()
"""

def __init__(self, dt=1):
Expand Down Expand Up @@ -322,6 +325,7 @@ class CacheProfiler(Callback):
manually.
>>> prof.clear()
>>> prof.unregister()
"""

Expand Down
1 change: 1 addition & 0 deletions dask/diagnostics/tests/test_progress.py
Expand Up @@ -68,6 +68,7 @@ def test_format_time():

def test_register(capsys):
try:
assert not Callback.active
p = ProgressBar()
p.register()

Expand Down

0 comments on commit 5b63301

Please sign in to comment.