Skip to content

Commit

Permalink
Delay lookup of allowed failures.
Browse files Browse the repository at this point in the history
This allows for setting the config after importing distributed

xref dask/dask-examples#75 (comment)
  • Loading branch information
TomAugspurger committed Jun 7, 2019
1 parent 5042f57 commit 277fd99
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 4 additions & 4 deletions distributed/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@
logger = logging.getLogger(__name__)


ALLOWED_FAILURES = dask.config.get("distributed.scheduler.allowed-failures")

LOG_PDB = dask.config.get("distributed.admin.pdb-on-err")
DEFAULT_DATA_SIZE = dask.config.get("distributed.scheduler.default-data-size")

Expand Down Expand Up @@ -829,7 +827,7 @@ def __init__(
synchronize_worker_interval="60s",
services=None,
service_kwargs=None,
allowed_failures=ALLOWED_FAILURES,
allowed_failures=None,
extensions=None,
validate=False,
scheduler_file=None,
Expand All @@ -846,7 +844,9 @@ def __init__(
self._setup_logging(logger)

# Attributes
self.allowed_failures = allowed_failures
self.allowed_failures = allowed_failures or dask.config.get(
"distributed.scheduler.allowed-failures"
)
self.validate = validate
self.status = None
self.proc = psutil.Process()
Expand Down
10 changes: 10 additions & 0 deletions distributed/tests/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1607,3 +1607,13 @@ async def test_async_context_manager():
assert w.status == "running"
assert s.workers
assert not s.workers


@pytest.mark.asyncio
async def test_allowed_failures_config():
async with Scheduler(port=0, allowed_failures=10) as s:
assert s.allowed_failures == 10

with dask.config.set({"distributed.scheduler.allowed_failures": 100}):
async with Scheduler(port=0) as s:
assert s.allowed_failures == 100

0 comments on commit 277fd99

Please sign in to comment.