File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 77import fsspec
88import psutil
99from dask .distributed import Client as DaskClient
10+ from distributed import LocalCluster
1011from jupyter_core .paths import jupyter_data_dir
1112from jupyter_server .transutils import _i18n
1213from jupyter_server .utils import to_os_path
@@ -402,6 +403,12 @@ class Scheduler(BaseScheduler):
402403 ),
403404 )
404405
406+ dask_cluster_url = Unicode (
407+ allow_none = True ,
408+ config = True ,
409+ help = "URL of the Dask cluster to connect to." ,
410+ )
411+
405412 db_url = Unicode (help = _i18n ("Scheduler database url" ))
406413
407414 task_runner = Instance (allow_none = True , klass = "jupyter_scheduler.task_runner.BaseTaskRunner" )
@@ -425,7 +432,10 @@ def __init__(
425432
426433 def _get_dask_client (self ):
427434 """Creates and configures a Dask client."""
428- return DaskClient ()
435+ if self .dask_cluster_url :
436+ return DaskClient (self .dask_cluster_url )
437+ cluster = LocalCluster (processes = True )
438+ return DaskClient (cluster )
429439
430440 @property
431441 def db_session (self ):
@@ -786,7 +796,7 @@ async def stop_extension(self):
786796 Cleanup code to run when the server is stopping.
787797 """
788798 if self .dask_client :
789- self .dask_client .close ()
799+ await self .dask_client .close ()
790800
791801
792802class ArchivingScheduler (Scheduler ):
You can’t perform that action at this time.
0 commit comments