if __name__ == '__main__': app = tornado.web.Application( handlers=[(r"/test/(\w+)", testHandler), (r'/', MainHandler)] ) server = tornado.httpserver.HTTPServer(app) server = server.listen(8848) tornado.ioloop.IOLoop.instance().start();
def get(self): res = {} pythoncom.CoInitialize() c = wmi.WMI() interfaces = c.Win32_PerfRawData_Tcpip_NetworkInterface() print len(interfaces) rec = send = 0.0 for t in interfaces: print t.Name rec += float(t.BytesReceivedPersec) / 1024 / 1024 send += float(t.BytesSentPersec) / 1024 / 1024 print rec, send res["receive"] = "%.2f" % rec res["send"] = "%.2f" % send self._write_json(res)
模块中很有很多类型(类型也有很多属性),在具体使用的过程中查询起来很痛苦。案例中的统计流量用的是Win32_PerfRawData_Tcpip_NetworkInterface ,也有解决方案用的是Win32_PerfRawData_Tcpip_TCPv4 两个统计到的数据差别很大,请根据实际情况来选择。
以上就是关于python方法无法在线程中使用的解决办法的详细内容,更多请关注Gxl网其它相关文章!
查看更多关于关于python方法无法在线程中使用的解决办法的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did84665