Command: Encapsulates a request as an object, thereby letting you parameterise clients with different requests, queue or log requests, and support undoable operations.
Threading In the Python standard library follows the command design pattern: The Client is the main thread and the receiver is the target thread. The Command is a callable Python object which is executed by calling its __call__()
method. The Invoker is the Thread
instance and its run()
method is equivalent to calling execute in the Command pattern. Thread
's run
method can be overridden in subclasses to customise the functionality beyond simply providing a function and input args
and kwargs
.