opened 02:46PM - 24 Feb 23 UTC
closed 02:57PM - 24 Feb 23 UTC
feature request
### Is there an existing issue for this?
- [X] I have searched the existing iss… ues
### Is your feature request related to a problem? Please describe.
Hot reloads don't pause background tasks
tittle(Chinese):热重载不会暂停后台任务
### Describe the solution you'd like
I've created a custom background task to start a single job thread (which will loop indefinitely), this thread will not be paused after sanic hot reload when I change the code, and I want to create a custom function for developers to define what needs to be done before hot reload
Chinese:我自定义了一个后台任务,用来启动一个单独作业的线程(这个线程会进行无限循环),当我更改代码,sanic热重载后,这个线程不会被暂停,我希望能自定义一个函数,用于开发者自定义在热重载前需要执行的操作
my code:
```
async def Start():
overview_Thread = threading.Thread(target=overview_Thread_Main, args=(JSON))
overview_Thread.start()
app.add_task(Start())
```
### Additional context
_No response_
I’ve created a custom background task to start a single job thread (which will loop indefinitely), this thread will not be paused after sanic hot reload when I change the code, and I want to create a custom function for developers to define what needs to be done before hot reload
Chinese:我自定义了一个后台任务,用来启动一个单独作业的线程(这个线程会进行无限循环),当我更改代码,sanic热重载后,这个线程不会被暂停,我希望能自定义一个函数,用于开发者自定义在热重载前需要执行的操作
async def Start():
overview_Thread = threading.Thread(target=overview_Thread_Main, args=(JSON))
overview_Thread.start()
app.add_task(Start())