@@ -154,6 +154,10 @@ class does handle all of the logic around asynchronously cleanly setting up
154
154
Whether or not we should silence logging when setting up the cluster.
155
155
name: str, optional
156
156
A name to use when printing out the cluster, defaults to type name
157
+ shutdown_on_close: bool
158
+ Whether or not to close the cluster when the program exits
159
+ shutdown_scheduler: bool
160
+ Whether or not to shut down the scheduler when the cluster is closed
157
161
158
162
Examples
159
163
--------
@@ -247,6 +251,7 @@ def __init__(
247
251
name = None ,
248
252
shutdown_on_close = True ,
249
253
scheduler_sync_interval = 1 ,
254
+ shutdown_scheduler = True ,
250
255
):
251
256
if loop is None and asynchronous :
252
257
loop = IOLoop .current ()
@@ -271,6 +276,7 @@ def __init__(
271
276
self ._correct_state_waiting = None
272
277
self ._name = name or type (self ).__name__
273
278
self .shutdown_on_close = shutdown_on_close
279
+ self .shutdown_scheduler = shutdown_scheduler
274
280
275
281
super ().__init__ (
276
282
asynchronous = asynchronous ,
@@ -450,13 +456,14 @@ async def _close(self):
450
456
451
457
if self .scheduler_comm :
452
458
async with self ._lock :
453
- with suppress (OSError ):
454
- await self .scheduler_comm .terminate ()
459
+ if self .shutdown_scheduler :
460
+ with suppress (OSError ):
461
+ await self .scheduler_comm .terminate ()
455
462
await self .scheduler_comm .close_rpc ()
456
463
else :
457
464
logger .warning ("Cluster closed without starting up" )
458
465
459
- if self .scheduler :
466
+ if self .scheduler and self . shutdown_scheduler :
460
467
await self .scheduler .close ()
461
468
for w in self ._created :
462
469
assert w .status in {
0 commit comments