# Run\_in\_thread for model-loading

**URL:** <https://forum.rasa.com/t/run-in-thread-for-model-loading/58380>\
**Category:** Rasa Open Source\
**Created:** [May 22, 2023, 4:51am UTC](https://forum.rasa.com/t/run-in-thread-for-model-loading/58380 "2023-05-22T04:51:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tejabhat](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/tejabhat/32/22658_2.png) [@tejabhat](https://forum.rasa.com/u/tejabhat)\
**Post date:** [May 22, 2023, 4:51am UTC](https://forum.rasa.com/t/run-in-thread-for-model-loading/58380/1 "2023-05-22T04:51:02Z")

</div>

Hi,

we have an issue that our rasa server stops responding while loading a new model.

But we realized that by using “@run\_in\_thread” in the /model api in server.py (as given below), makes it non-blocking and serves our purpose.

But how can I override this api in a graceful manner without touching the rasa code. Please give us some hints if possible.

```
@app.put("/model")
**@run_in_thread**
@requires_auth(app, auth_token)
async def load_model(request: Request) -> HTTPResponse:

```

Best Regards, tejaswini

---

<div class="post-metadata">

**Author:** ![stephens](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/stephens/32/1632_2.png) [@stephens](https://forum.rasa.com/u/stephens)\
**Post date:** [May 23, 2023, 7:56pm UTC](https://forum.rasa.com/t/run-in-thread-for-model-loading/58380/2 "2023-05-23T19:56:44Z")

</div>

I don’t know that you can resolve the issue with that approach. I normally see users bringing up multiple instances and using a load balancer as a proxy to switch from an instance with the old model to another instance with the new model.
