Best practice for shutting down a cluster

I’ve got a LocalCluster working well except for teardown. I’ve tried a number of functions, including:

  • client.close()
  • client.shutdown()
  • client.scheduler.shutdown()
  • client.retire_workers()
  • doing nothing

But I’ve found no combination that avoids a variety of errors on exit. All the examples I’ve found are interactive ipynb files that don’t ever terminate the cluster. So basic question:

What is the best practice for cleanly terminating a client / cluster?


Hi @rjplevin,

This is also something that I’ve experienced, and I’ve no good advice. I’d say the better to use is client.shutdown(), but it’s true in some workload you can get random errors… In general, you can safely ignore them, but I agree this isn’t really clean.

Is there any way to supress these errors or redirect them somewhere else?
I’ve tried:
- Redirecting stderr and stdout before calling client.shutdown();
- Changing the logging.distributed in the dask.config Configuration dictionary to error level;
- Using client.register_worker_callbacks() to call a function that silences logging everytime a worker is created.
However, I can’t seem to ever silence the WARNING messages I get when I shutdown the client. I am building an application using Dask and I would like the users to not see these “alarming” messages if they do not have to.

Hi @byrom771, welcome here!

Could you give us the errors you are seeing?