Commit 0c207a6
committed
Properly keep references and await for concurrent tasks
The data sourcing actor is parallelizing the sending of samples to the
stream senders, but it was not properly keeping references to the tasks
and awaiting for them to finish.
References were probably kept by `gather()`, but `gather()` wasn't
awaited, so it can potentially not run at all (although it seems it did,
because things were working).
This commit uses a `TaskGroup` to keep references to the tasks in
`process_msg()` and then makes each `process_msg()` call a task too, but
we don't use a task group here because we don't want to await until
a batch of messages is sent before receiving the next one. Instead, we
want to keep sending messages in the background. But we still need to
clean up these tasks as soon as they are done.
This replaces the event used to wait until there are no more pending
messages to be sent, as it is enough to synchronize awaiting for the
(pending) tasks to finish.
Signed-off-by: Leandro Lucarella <[email protected]>1 parent 2faab71 commit 0c207a6
File tree
2 files changed
+26
-22
lines changed- src/frequenz/sdk/actor/_data_sourcing
2 files changed
+26
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
Lines changed: 25 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
398 | 398 | | |
399 | 399 | | |
400 | 400 | | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
412 | 421 | | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
| 422 | + | |
418 | 423 | | |
419 | 424 | | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
426 | 428 | | |
| 429 | + | |
427 | 430 | | |
428 | 431 | | |
429 | 432 | | |
| |||
0 commit comments