# Implement time out when creating the model

**URL:** <https://discourse.julialang.org/t/implement-time-out-when-creating-the-model/89451>\
**Category:** Optimization (Mathematical)\
**Created:** [October 28, 2022, 12:58pm UTC](https://discourse.julialang.org/t/implement-time-out-when-creating-the-model/89451 "2022-10-28T12:58:00Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [October 28, 2022, 1:28pm UTC](https://discourse.julialang.org/t/implement-time-out-when-creating-the-model/89451/2 "2022-10-28T13:28:03Z")

</div>

It seems you want to change the API to (optionally) terminate. That’s always possible for some code. A lot of code has timeouts, and you could make a PR to JuMP, though I’m not sure if it’s wanted, too much overhead? [The user couldn’t add timeouts from the calling code (unless your calling code that korks a new Julia process).]

If it’s just a hack, to not take up resources (e.g. on a cluster), you can stop any process after some time, with the `timeout` command (I guess e.g. Windows might have similar, or could do in WSL2):

> <https://serverfault.com/questions/166034/kill-all-processes-that-are-running-for-more-than-5-minutes-by-a-given-user-in-l/776531#776531>

but you got me interested in knowing if you can stop some code from within the program, and my first thought was start it as a thread, and if there’s a way to time-limit it. That doesn’t seem to be the case in most languages, at least not Julia (safely, is it still possible, if you basically want to terminate after?) or C (likely possible in Elixir/Erlang, and Java?):

> [@How to kill thread?](https://discourse.julialang.org/t/how-to-kill-thread/34236):
>
> Is there a way to kill a thread spawned by Threads.@spawn macro?

> <https://stackoverflow.com/questions/70234333/c-kill-long-running-thread-by-sigint>

> **[How to stop/kill long running Java Thread at runtime? timed-out -\>...](https://crunchify.com/java-thread-futures-timedout-cancelled-interrupted/)**
>
> Have you ever wondered how to kill long running Java thread? Do you have any of below questions? Kill/Stop a thread after certain period of time Killing

---

_[View the full topic](https://discourse.julialang.org/t/implement-time-out-when-creating-the-model/89451)._
