I got an error with concurrent task. Can anyone help?
from runtime.asyncrt import TaskGroup
@parameter
@always_inline
async fn task1():
while True:
pass
fn main() raises:
var tg = TaskGroup()
tg.create_task(task1())
while True:
pass
$ mojo life.mojo
LLVM ERROR: destroying a non-available AsyncValue isn't implemented
Aborted (core dumped)
duck_tape
(Seth Stadick)
2
You need to call .wait
.
from runtime.asyncrt import TaskGroup
@parameter
@always_inline
async fn task1():
while True:
pass
fn main() raises:
var tg = TaskGroup()
tg.create_task(task1())
tg.wait()
The compiler is destroying the tg after its last use, which is before that loop, which is what the error message is about.
How to let the concurrent task runs forever without waiting for its completion?
sora
4
Regardless of the helpful fix suggested by @duck_tape, I think the compiler should fail more gracefully. Could you please file a bug on GitHub?
1 Like