我需要知道为什么当我运行以下代码时它会给我这个错误
Traceback (most recent call last):
File "C:\Users\moksh\Desktop\moksh.py", line 29, in <module>
server_B_thread.start()
error: can't start new thread
代码:
#!/usr/bin/python
import threading
import time
import SocketServer
import socket
class ThreadedTCPRequestHandler(SocketServer.BaseRequestHandler):
def handle(self):
self.allow_reuse_address = True
self.data = self.request.recv(1024).strip()
print "%s wrote: " % self.client_address[0]
print 'Connection from',self.client_address[0]
print self.data
self.request.send(self.data.upper())
class ThreadedTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
pass
if __name__ == "__main__":
HOST = '0.0.0.0'
PORT = 1000
while PORT <1900:
server_B = ThreadedTCPServer((HOST, PORT), ThreadedTCPRequestHandler)
server_B_thread = threading.Thread(target=server_B.serve_forever)
server_B_thread.setDaemon(True)
server_B_thread.start()
PORT +=1
while 1:
time.sleep(1)