sync.WorkGroup: Provide "with" support
So that it becomes possible to write with WorkGroup(ctx) as wg: wg.go(f1) wg.go(f2) instead of wg = WorkGroup(ctx) defer(wg.wait) wg.go(f1) wg.go(f2) or wg = WorkGroup(ctx) wg.go(f1) wg.go(f2) wg.wait() This is sometimes handy and is referred to as "structured concurrency" in Python world. sync.Sema, sync.Mutex, sync.RWMutex already support "with". sync.WaitGroup is imho too low-level, but we might consider adding "with" support for it in the future as well. In general pygolang way is to use defer instead of plugging all classes with __enter__/__exit__ "with" support, but for small well-known class of concurrency-related things its seems "with" support is worth it: - having "with" for sync.Mutex+co allows it to be used as a drop-in replacement instead of threading.Lock+co, and - having "with" for sync.WorkGroup - the most commonly-used tool to spawn jobs and wait for their completion - makes it on-par with "structured concurrency". /reviewed-on !12
Status | Job ID | Name | Coverage | ||||||
---|---|---|---|---|---|---|---|---|---|
External | |||||||||
failed |
#130994
external
|
Pygolang.UnitTest-Master.Python2 |
00:01:26
|
||||||
passed |
#130956
external
|
Pygolang.UnitTest-Master.Python3 |
00:01:40
|
||||||
passed |
#130474
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:12
|
||||||
passed |
#130609
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:04
|
||||||
passed |
#130432
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:11
|
||||||
passed |
#130615
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:11
|
||||||
passed |
#130484
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:13
|
||||||
passed |
#130620
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:10
|
||||||
passed |
#130386
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:30:02
|
||||||
passed |
#130624
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:07
|
||||||
passed |
#130491
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:09
|
||||||
passed |
#130629
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:03
|
||||||
passed |
#130438
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:11
|
||||||
passed |
#130635
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:06
|
||||||
passed |
#130496
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:06
|
||||||
passed |
#130641
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:05
|
||||||
passed |
#130413
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:07
|
||||||
passed |
#130647
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:06
|
||||||
passed |
#130503
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:12
|
||||||
passed |
#130653
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:05
|
||||||
passed |
#130445
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:10
|
||||||
passed |
#130660
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:06
|
||||||
passed |
#130513
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:13
|
||||||
passed |
#130665
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:05
|
||||||
passed |
#130402
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:07
|
||||||
passed |
#130675
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:06
|
||||||
passed |
#130522
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:09
|
||||||
passed |
#130684
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:06
|
||||||
passed |
#130450
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:45
|
||||||
passed |
#130690
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:05
|
||||||
passed |
#130558
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:36
|
||||||
passed |
#130697
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:03
|
||||||
passed |
#130419
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:07
|
||||||
passed |
#130705
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:08
|
||||||
passed |
#130564
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:32
|
||||||
passed |
#130712
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:05
|
||||||
passed |
#130456
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:05
|
||||||
passed |
#130717
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:04
|
||||||
passed |
#130572
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:18
|
||||||
passed |
#130723
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:06
|
||||||
passed |
#130395
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:14
|
||||||
passed |
#130729
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:13
|
||||||
passed |
#130580
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:14
|
||||||
passed |
#130737
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:07
|
||||||
passed |
#130462
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:13
|
||||||
passed |
#130585
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:13
|
||||||
passed |
#130425
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:05
|
||||||
passed |
#130590
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:16
|
||||||
passed |
#130826
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:30
|
||||||
failed |
#130469
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:02:37
|
||||||
passed |
#130867
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:54
|
||||||
passed |
#130595
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:09
|
||||||
passed |
#130877
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:21
|
||||||
passed |
#130408
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:12
|
||||||
passed |
#130603
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:08
|
||||||
passed |
#130908
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:11
|
||||||
failed |
#130941
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:40
|
||||||
passed |
#130957
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:34
|
||||||
passed |
#130959
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:35
|
||||||
passed |
#130811
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:02:11
|
||||||
passed |
#130866
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:46
|
||||||
passed |
#130871
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:46
|
||||||
passed |
#130878
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:25
|
||||||
passed |
#130896
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:50
|
||||||
passed |
#130742
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:24
|
||||||
passed |
#130370
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:09
|
||||||
passed |
#130371
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:10
|
||||||
passed |
#130377
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:07
|
||||||
passed |
#130383
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:09
|
||||||
passed |
#130391
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:11
|
||||||
passed |
#130398
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:55
|
||||||
passed |
#130403
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:15
|
||||||
failed |
#130409
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:23
|
||||||
passed |
#130415
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:18
|
||||||
passed |
#130421
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:22
|
||||||
passed |
#130428
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:18
|
||||||
passed |
#130434
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:42
|
||||||
passed |
#130440
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:14
|
||||||
passed |
#130447
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:12
|
||||||
passed |
#130453
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:32
|
||||||
passed |
#130459
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:09
|
||||||
passed |
#130464
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:23
|
||||||
failed |
#130470
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:02:01
|
||||||
passed |
#130476
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:20
|
||||||
passed |
#130486
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:13
|
||||||
passed |
#130493
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:14
|
||||||
passed |
#130499
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:15
|
||||||
failed |
#130506
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:21
|
||||||
passed |
#130515
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:13
|
||||||
passed |
#130554
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:50
|
||||||
passed |
#130560
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:37
|
||||||
passed |
#130567
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:26
|
||||||
passed |
#130575
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:02:17
|
||||||
passed |
#130581
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:23
|
||||||
passed |
#130587
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:11
|
||||||
passed |
#130592
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:20
|
||||||
passed |
#130597
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:22
|
||||||
passed |
#130605
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:10
|
||||||
passed |
#130611
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:07
|
||||||
passed |
#130616
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:08
|
||||||
passed |
#130621
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:08
|
||||||
passed |
#130626
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:09
|
||||||
passed |
#130632
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:07
|
||||||
passed |
#130637
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:11
|
||||||
passed |
#130643
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:07
|
||||||
passed |
#130649
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:10
|
||||||
passed |
#130656
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:08
|
||||||
passed |
#130662
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:10
|
||||||
passed |
#130670
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:06
|
||||||
passed |
#130678
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:06
|
||||||
passed |
#130686
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:09
|
||||||
passed |
#130692
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:08
|
||||||
passed |
#130701
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:06
|
||||||
passed |
#130708
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:08
|
||||||
passed |
#130714
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:07
|
||||||
passed |
#130719
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:07
|
||||||
passed |
#130725
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:08
|
||||||
passed |
#130733
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:20
|
||||||
passed |
#130311
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:26
|
||||||
passed |
#130758
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:02:11
|
||||||
passed |
#130778
external
retried
|
Pygolang.UnitTest-Master.Python3 |
00:01:48
|
||||||