我不小心点击ctrl z而不是ctrl c来停止python SimpleHTTPServer,它出现了
[1] + 35296 suspended python -m SimpleHTTPServer
现在我无法在端口8000正在使用的同一端口重启它
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SimpleHTTPServer.py", line 220, in <module>
test()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SimpleHTTPServer.py", line 216, in test
BaseHTTPServer.test(HandlerClass, ServerClass)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/BaseHTTPServer.py", line 595, in test
httpd = ServerClass(server_address, HandlerClass)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 419, in __init__
self.server_bind()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/BaseHTTPServer.py", line 108, in server_bind
SocketServer.TCPServer.server_bind(self)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 430, in server_bind
self.socket.bind(self.server_address)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 48] Address already in use
如何停止此过程以便我可以再次使用端口8000?
由于
答案 0 :(得分:2)
杀死这个过程。
kill 35296
或:
kill %1
答案 1 :(得分:2)
此过程在后台暂停,您必须将其终止才能释放该端口。
如果您在同一个终端中,运行fg
会将其置于最前面并重新激活它,让您通过 CTRL + C <正常中断它/ KBD>
如果你没有,你可以使用那个被打印的号码(进程ID或PID)来杀死它,但是你首先必须重新激活它,以便它可以做出反应: / p>
kill -CONT 35296
kill 35296
答案 2 :(得分:1)
使用fg
将它带到前台,然后你可以使用ctrl + c