无法关闭位置服务器,python TCPServer address已在使用中,但我关闭服务器并使用“allow\u reuse”地址`...

以下是运行服务器的代码:class MyRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):

#....

PORT = 8089

httpd = SocketServer.TCPServer(("", PORT), MyRequestHandler)

httpd.allow_reuse_address = True

print "Serving forever at port", PORT

try:

httpd.serve_forever()

except:

print "Closing the server."

httpd.server_close()

raise

但这就是发生的事:^CClosing the server.

Traceback (most recent call last):

File "server.py", line 118, in

self.send_error(400, "Unimplemented GET command: %s" % (self.path,))

File "/home/claudiu/local/lib/python2.6/SocketServer.py", line 224, in serve_forever

r, w, e = select.select([self], [], [], poll_interval)

keyboardInterrupt

(.virtualenv)claudiu@xxx:~/xxx$ python server.py

Traceback (most recent call last):

File "server.py", line 122, in

httpd = SocketServer.TCPServer(("", PORT), MyRequestHandler)

File "/home/claudiu/local/lib/python2.6/SocketServer.py", line 402, in __init__

self.server_bind()

File "/home/claudiu/local/lib/python2.6/SocketServer.py", line 413, in server_bind

self.socket.bind(self.server_address)

File "", line 1, in bind

socket.error: [Errno 98] Address already in use

为什么?我关闭服务器并将allow_reuse_address设置为True。。。使用Python2.6.8。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值