9
9
from typing import (
10
10
Any ,
11
11
Callable ,
12
+ Mapping ,
12
13
NoReturn ,
13
14
Optional ,
14
15
Sequence ,
@@ -105,7 +106,9 @@ async def raise_from_exception_queue() -> NoReturn:
105
106
# tasks as we do start operation tasks?
106
107
asyncio .create_task (
107
108
self ._handle_cancel_operation_task (
108
- task .request .cancel_operation , task .task_token
109
+ task .task_token ,
110
+ task .request .cancel_operation ,
111
+ dict (task .request .header ),
109
112
)
110
113
)
111
114
else :
@@ -155,17 +158,22 @@ async def wait_all_completed(self) -> None:
155
158
# "Any call up to this function and including this one will be trimmed out of stack traces.""
156
159
157
160
async def _handle_cancel_operation_task (
158
- self , request : temporalio .api .nexus .v1 .CancelOperationRequest , task_token : bytes
161
+ self ,
162
+ task_token : bytes ,
163
+ request : temporalio .api .nexus .v1 .CancelOperationRequest ,
164
+ headers : Mapping [str , str ],
159
165
) -> None :
160
166
"""
161
167
Handle a cancel operation task.
162
168
163
169
Attempt to execute the user cancel_operation method. Handle errors and send the
164
170
task completion.
165
171
"""
172
+ # TODO(nexus-prerelease): headers
166
173
ctx = CancelOperationContext (
167
174
service = request .service ,
168
175
operation = request .operation ,
176
+ headers = headers ,
169
177
)
170
178
_temporal_operation_context .set (
171
179
_TemporalNexusOperationContext (
@@ -174,7 +182,6 @@ async def _handle_cancel_operation_task(
174
182
client = self ._client ,
175
183
)
176
184
)
177
- # TODO(nexus-prerelease): headers
178
185
try :
179
186
await self ._handler .cancel_operation (ctx , request .operation_token )
180
187
except Exception as err :
@@ -202,7 +209,7 @@ async def _handle_start_operation_task(
202
209
self ,
203
210
task_token : bytes ,
204
211
start_request : temporalio .api .nexus .v1 .StartOperationRequest ,
205
- headers : dict [str , str ],
212
+ headers : Mapping [str , str ],
206
213
) -> None :
207
214
"""
208
215
Handle a start operation task.
@@ -243,7 +250,7 @@ async def _handle_start_operation_task(
243
250
async def _start_operation (
244
251
self ,
245
252
start_request : temporalio .api .nexus .v1 .StartOperationRequest ,
246
- headers : dict [str , str ],
253
+ headers : Mapping [str , str ],
247
254
) -> temporalio .api .nexus .v1 .StartOperationResponse :
248
255
"""
249
256
Invoke the Nexus handler's start_operation method and construct the StartOperationResponse.
0 commit comments