decorators#
Module: zmq.decorators#
Decorators for running functions with context/sockets.
Added in version 15.3.
Like using Contexts and Sockets as context managers, but with decorator syntax. Context and sockets are closed at the end of the function.
For example:
from zmq.decorators import context, socket
@context()
@socket(zmq.PUSH)
def work(ctx, push):
...
Decorators#
- zmq.decorators.context(*args: Any, **kwargs: Any) _DecoratorCallable#
Decorator for adding a Context to a function.
Usage:
@context() def foo(ctx): ...
Added in version 15.3.
- Parameters:
name (str) – the keyword argument passed to decorated function