MCPcopy
hub / github.com/Bogdanp/dramatiq / message_with_options

Method message_with_options

dramatiq/actor.py:104–138  ·  view source on GitHub ↗

Build a message with an arbitrary set of processing options. This method is useful if you want to compose actors. See the actor composition documentation for details. Parameters: args(tuple): Positional arguments that are passed to the actor. kwargs(dict

(
        self,
        *,
        args: tuple = (),
        kwargs: Optional[dict[str, Any]] = None,
        **options,
    )

Source from the content-addressed store, hash-verified

102 return self.message_with_options(args=args, kwargs=kwargs)
103
104 def message_with_options(
105 self,
106 *,
107 args: tuple = (),
108 kwargs: Optional[dict[str, Any]] = None,
109 **options,
110 ) -> Message[R]:
111 """Build a message with an arbitrary set of processing options.
112 This method is useful if you want to compose actors. See the
113 actor composition documentation for details.
114
115 Parameters:
116 args(tuple): Positional arguments that are passed to the actor.
117 kwargs(dict): Keyword arguments that are passed to the actor.
118 **options: Arbitrary options that are passed to the
119 broker and any registered middleware.
120
121 Returns:
122 Message: A message that can be enqueued on a broker.
123 """
124 for name in ["on_failure", "on_success"]:
125 callback = options.get(name)
126 if isinstance(callback, Actor):
127 options[name] = callback.actor_name
128
129 elif not isinstance(callback, (type(None), str)):
130 raise TypeError(name + " value must be an Actor")
131
132 return Message(
133 queue_name=self.queue_name,
134 actor_name=self.actor_name,
135 args=args,
136 kwargs=kwargs or {},
137 options=options,
138 )
139
140 def send(self, *args: P.args, **kwargs: P.kwargs) -> Message[R]:
141 """Asynchronously send a message to this actor.

Calls 1

MessageClass · 0.85