退出Django dev服务器,但进程不会停止

时间:2021-05-29 21:14:04

I'm developing on Mac OSX 10.8. Lately I've been noticing that when I've been running the dev server for a while, and then -C to exit, the process continues to run in the background. I have to do a ps to find the process and kill it, or it won't let me use the same address:port again.

我正在Mac OSX 10.8上开发。最近我注意到,当我运行dev服务器一段时间,然后-C退出时,该过程继续在后台运行。我必须做一个ps来找到进程并杀死它,否则它不会让我使用相同的地址:端口再次。

I didn't have to do that in earlier versions of Django (I'm currently running 1.7.3 on this project). Seems a bit messy, but don't know of another way to stop the dev server and free the port/resources?

我没有在早期版本的Django中做到这一点(我目前在这个项目上运行1.7.3)。似乎有点凌乱,但不知道另一种方法来停止开发服务器并释放端口/资源?

Rgds, Ross.

Rgds,罗斯。

1 个解决方案

#1


1  

Django development server have multiple threads, so when closing main process, there might be some running threads in background. It happens when there is some request being processed (some long-term request can hang or if you're using websockets or something, connection might prevent closing thread).

Django开发服务器有多个线程,因此在关闭主进程时,后台可能会有一些正在运行的线程。当有一些请求被处理时会发生这种情况(某些长期请求可能会挂起,或者如果您使用的是websockets或其他东西,连接可能会阻止关闭线程)。

Check if all of your requests are properly closed before closing your server and it should shut down properly.

在关闭服务器之前检查所有请求是否已正确关闭,并且应该正常关闭。

#1


1  

Django development server have multiple threads, so when closing main process, there might be some running threads in background. It happens when there is some request being processed (some long-term request can hang or if you're using websockets or something, connection might prevent closing thread).

Django开发服务器有多个线程,因此在关闭主进程时,后台可能会有一些正在运行的线程。当有一些请求被处理时会发生这种情况(某些长期请求可能会挂起,或者如果您使用的是websockets或其他东西,连接可能会阻止关闭线程)。

Check if all of your requests are properly closed before closing your server and it should shut down properly.

在关闭服务器之前检查所有请求是否已正确关闭,并且应该正常关闭。