基于系统运行情况优化
多进程下判断进程的消耗情况
首先根据程序中通过进程名进行区分,通过setproctitle库设置进程对应的名称
server = socketserver.ThreadingUDPServer(('0.0.0.0', 21800), MyHandler)
setproctitle.setproctitle('python3- 雷达基础接收服务')
for i in mac_list:
deal = Process(target=deal_data, args=(mac_list[i][1],))
deal.daemon = True
deal.start()
setproctitle.setproctitle('python3- 雷达处理服务--%s' % i)
server.serve_forever()
通过命令查看服务 ps -ef | grep python3
[root@localhost ~]# ps -ef | grep python3
root 5071 1 1 10月09 ? 00:18:54 python3 server2.py
root 5072 5071 3 10月09 ? 00:51:33 python3 server2.py
root 5073 5071 3 10月09 ? 00:47:38 python3 server2.py
root 5074 5071 3 10月09 ? 00:47:33 python3 server2.py
root 5075 5071 3 10月09 ? 00:47:36 python3 server2.py
root 5076 5071 3 10月09 ? 00:47:44 python3 server2.py
root 74806 1 0 10月09 ? 00:00:35 python3 api.py
root 157028 126644 29 13:47 pts/4 00:00:00 python3- ?达处理服务--32:06:02:44:00:4b
root 157030 157028 10 13:47 pts/4 00:00:00 python3- ?达基础接收服务
root 157469 48112 0 13:47 pts/5 00:00:00 grep --color=auto python3
python3 -m memray run --live server.py 实时分析内存情况
版权说明
本文地址:http://www.liuyangdeboke.cn/?post=54
未标注转载均为本站远程,转载请注明文章出处:
发表评论