Command

Package a request as an object

Command turns a request into a standalone object with an execute method, so you can queue it, log it, retry it, or undo it. Background jobs are the perfect fit: each job is a command; a runner just calls each one.

In Python any callable is already a command โ€” a function, a lambda, or an object with __call__. The pattern earns its keep when the command also needs to carry state or support undo.