@@ -136,6 +136,15 @@ class ConversationHandler(Handler[Update]):
136
136
map_to_parent (Dict[:obj:`object`, :obj:`object`], optional): A :obj:`dict` that can be
137
137
used to instruct a nested conversationhandler to transition into a mapped state on
138
138
its parent conversationhandler in place of a specified nested state.
139
+ run_async (:obj:`bool`, optional): Pass :obj:`True` to *override* the
140
+ :attr:`Handler.run_async` setting of all handlers (in :attr:`entry_points`,
141
+ :attr:`states` and :attr:`fallbacks`).
142
+
143
+ Note:
144
+ If set to :obj:`True`, you should not pass a handler instance, that needs to be
145
+ run synchronously in another context.
146
+
147
+ .. versionadded:: 13.2
139
148
140
149
Raises:
141
150
ValueError
@@ -168,6 +177,10 @@ class ConversationHandler(Handler[Update]):
168
177
map_to_parent (Dict[:obj:`object`, :obj:`object`]): Optional. A :obj:`dict` that can be
169
178
used to instruct a nested conversationhandler to transition into a mapped state on
170
179
its parent conversationhandler in place of a specified nested state.
180
+ run_async (:obj:`bool`): If :obj:`True`, will override the
181
+ :attr:`Handler.run_async` setting of all internal handlers on initialization.
182
+
183
+ .. versionadded:: 13.2
171
184
172
185
"""
173
186
@@ -192,8 +205,9 @@ def __init__(
192
205
name : str = None ,
193
206
persistent : bool = False ,
194
207
map_to_parent : Dict [object , object ] = None ,
208
+ run_async : bool = False ,
195
209
):
196
- self .run_async = False
210
+ self .run_async = run_async
197
211
198
212
self ._entry_points = entry_points
199
213
self ._states = states
@@ -229,7 +243,7 @@ def __init__(
229
243
"since message IDs are not globally unique."
230
244
)
231
245
232
- all_handlers = list ()
246
+ all_handlers : List [ Handler ] = list ()
233
247
all_handlers .extend (entry_points )
234
248
all_handlers .extend (fallbacks )
235
249
@@ -263,6 +277,10 @@ def __init__(
263
277
)
264
278
break
265
279
280
+ if self .run_async :
281
+ for handler in all_handlers :
282
+ handler .run_async = True
283
+
266
284
@property
267
285
def entry_points (self ) -> List [Handler ]:
268
286
return self ._entry_points
0 commit comments