Disconnect Client#

Shows how to disconnect a client session, clear client resources, and optionally stop the cluster.

"""Basic client clear/disconnect example with a local cluster."""

from scaler import Client
from scaler.cluster.combo import SchedulerClusterCombo


def main():
    cluster = SchedulerClusterCombo(n_workers=10)
    client = Client(address=cluster.get_address())
    client.clear()
    client.disconnect()

    cluster.shutdown()


if __name__ == "__main__":
    main()

What the example does:

  • Starts a local cluster and creates a client.

  • Calls clear() to cancel unfinished tasks and clear client-owned resources.

  • Calls disconnect() to close only this client session.

Use disconnect when you want to close one client without stopping the scheduler.

Shutdown behavior#

By default, the scheduler runs in protected mode. See protected for details.

If protected mode is disabled, clients can stop the cluster by calling shutdown().