|
77 | 77 | logger = logging.getLogger(__name__) |
78 | 78 |
|
79 | 79 |
|
| 80 | +logging_levels = { |
| 81 | + name: logger.level |
| 82 | + for name, logger in logging.root.manager.loggerDict.items() |
| 83 | + if isinstance(logger, logging.Logger) |
| 84 | +} |
| 85 | + |
80 | 86 | _TEST_TIMEOUT = 30 |
81 | 87 | _offload_executor.submit(lambda: None).result() # create thread during import |
82 | 88 |
|
@@ -209,6 +215,14 @@ def get_ip(): |
209 | 215 | remote_magic._clients.clear() |
210 | 216 |
|
211 | 217 |
|
| 218 | +original_config = copy.deepcopy(dask.config.config) |
| 219 | + |
| 220 | + |
| 221 | +def reset_config(): |
| 222 | + dask.config.config.clear() |
| 223 | + dask.config.config.update(copy.deepcopy(original_config)) |
| 224 | + |
| 225 | + |
212 | 226 | def nodebug(func): |
213 | 227 | """ |
214 | 228 | A decorator to disable debug facilities during timing-sensitive tests. |
@@ -1571,13 +1585,18 @@ def clean(threads=not WINDOWS, instances=True, timeout=1, processes=True): |
1571 | 1585 | with check_process_leak(check=processes): |
1572 | 1586 | with check_instances() if instances else nullcontext(): |
1573 | 1587 | with check_active_rpc(loop, timeout): |
1574 | | - with dask.config.set( |
1575 | | - {"distributed.comm.timeouts.connect": "5s"} |
1576 | | - ): |
1577 | | - yield loop |
| 1588 | + reset_config() |
| 1589 | + |
| 1590 | + dask.config.set({"distributed.comm.timeouts.connect": "5s"}) |
| 1591 | + # Restore default logging levels |
| 1592 | + # XXX use pytest hooks/fixtures instead? |
| 1593 | + for name, level in logging_levels.items(): |
| 1594 | + logging.getLogger(name).setLevel(level) |
| 1595 | + |
| 1596 | + yield loop |
1578 | 1597 |
|
1579 | | - with suppress(AttributeError): |
1580 | | - del thread_state.on_event_loop_thread |
| 1598 | + with suppress(AttributeError): |
| 1599 | + del thread_state.on_event_loop_thread |
1581 | 1600 |
|
1582 | 1601 |
|
1583 | 1602 | @pytest.fixture |
|
0 commit comments