我有带有 httpHandler 类的 python 文件。我将它与 ThreadingMixIn 一起使用,如下所示:
from SocketServer import ThreadingMixIn
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
Successful_Attempts = 0
Failed_Attempts = 0
class httpHandler(BaseHTTPRequestHandler):
def do_POST(self):
.....
class ThreadingHTTPServer(ThreadingMixIn, HTTPServer):
pass
后来我按如下方式启动它:
server = ThreadingHTTPServer(('localhost', PORT_NUMBER), httpHandler)
print 'Started httpserver on port ' , PORT_NUMBER
据我了解,一旦建立连接,httpHandler 类就已经在另一个线程中。我想跟踪我的线程,某种统计处理。但是我无法访问我的变量。另外,我需要锁定它们,以便它们代表真实值,而不是未正确定义的东西