@@ -216,7 +216,8 @@ async def cant42(task_no):
216
216
217
217
# Test await syntax and throwing exception to subtask
218
218
@asyn .cancellable
219
- async def chained (task_id ):
219
+ async def chained (task_id , x , y , * , red , blue ):
220
+ print ('Args:' , x , y , red , blue ) # Test args and kwargs
220
221
task_no = task_id ()
221
222
try :
222
223
await cant42 (task_no )
@@ -229,7 +230,7 @@ async def run_cancel_test4():
229
230
loop .create_task (asyn .Cancellable (cant40 )()) # 3 instances in default group 0
230
231
loop .create_task (asyn .Cancellable (cant40 )())
231
232
loop .create_task (asyn .Cancellable (cant40 )())
232
- loop .create_task (asyn .Cancellable (chained , group = 1 )())
233
+ loop .create_task (asyn .Cancellable (chained , 1 , 2 , red = 3 , blue = 4 , group = 1 )())
233
234
loop .create_task (asyn .Cancellable (cant41 )()) # Runs to completion
234
235
print ('Running tasks' )
235
236
await asyncio .sleep (3 )
@@ -246,6 +247,7 @@ def test4():
246
247
printexp ('''Task cant41 no. 0 running, arg 5.
247
248
Task cant41 no. 0 ended.
248
249
Running tasks
250
+ Args: 1 2 3 4
249
251
Task cant42 no. 4 running
250
252
Task cant40 no. 1 running.
251
253
Task cant40 no. 2 running.
@@ -278,7 +280,7 @@ async def start(self, loop):
278
280
loop .create_task (asyn .Cancellable (self .foo , 1 )()) # 3 instances in default group 0
279
281
loop .create_task (asyn .Cancellable (self .foo , 2 )())
280
282
loop .create_task (asyn .Cancellable (self .foo , 3 )())
281
- loop .create_task (asyn .NamedTask ('my bar' , self .bar , 4 )())
283
+ loop .create_task (asyn .NamedTask ('my bar' , self .bar , 4 , y = 42 )())
282
284
await asyncio .sleep (4.5 )
283
285
await asyn .NamedTask .cancel ('my bar' )
284
286
await asyn .Cancellable .cancel_all ()
@@ -295,31 +297,31 @@ async def foo(self, _, arg):
295
297
print ('foo was cancelled' )
296
298
297
299
@asyn .cancellable
298
- async def bar (self , _ , arg ):
300
+ async def bar (self , _ , arg , * , x = 1 , y = 2 ):
299
301
try :
300
302
while True :
301
303
await asyn .sleep (1 )
302
- print ('bar running, arg' , arg )
304
+ print ('bar running, arg' , arg , x , y )
303
305
except asyn .StopTask :
304
306
print ('bar was cancelled' )
305
307
306
308
def test5 ():
307
309
printexp ('''foo running, arg 1
308
310
foo running, arg 2
309
311
foo running, arg 3
310
- bar running, arg 4
312
+ bar running, arg 4 1 42
311
313
foo running, arg 1
312
314
foo running, arg 2
313
315
foo running, arg 3
314
- bar running, arg 4
316
+ bar running, arg 4 1 42
315
317
foo running, arg 1
316
318
foo running, arg 2
317
319
foo running, arg 3
318
- bar running, arg 4
320
+ bar running, arg 4 1 42
319
321
foo running, arg 1
320
322
foo running, arg 2
321
323
foo running, arg 3
322
- bar running, arg 4
324
+ bar running, arg 4 1 42
323
325
foo was cancelled
324
326
foo was cancelled
325
327
foo was cancelled
0 commit comments