# "kill" internal execution

**URL:** https://discourse.julialang.org/t/kill-internal-execution/73144
**Category:** General Usage
**Tags:** task
**Created:** [December 15, 2021, 1:28pm UTC](https://discourse.julialang.org/t/kill-internal-execution/73144 "2021-12-15T13:28:49Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)
#### Post date: [December 15, 2021, 6:17pm UTC](https://discourse.julialang.org/t/kill-internal-execution/73144/4 "2021-12-15T18:17:17Z")

</div>

You can’t use `throwto` or `schedule(_, exception; error = true)` on an arbitrary task that is already started [Stop/terminate a (sub)task started with @async - #5 by jameson](https://discourse.julialang.org/t/stop-terminate-a-sub-task-started-with-async/32193/5).

If you are curious, see [https://github.com/JuliaLang/julia/pull/41270](https://github.com/JuliaLang/julia/pull/41270) for exactly when `schedule` can be called on a task that is already started. But I don’t think it’d be useful for the use case mentioned in the OP.

Probably the only way to do this reliably is to do the benchmark in a child process. (Or use something like Cassette to inject the cancellation token; but it’d change the program that is benchmarked.)

---

_[View the full topic](https://discourse.julialang.org/t/kill-internal-execution/73144)._
