亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

python psutil監(jiān)控進(jìn)程實(shí)例

 更新時(shí)間:2019年12月17日 14:54:20   作者:qq_3158353  
今天小編就為大家分享一篇python psutil監(jiān)控進(jìn)程實(shí)例,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧

我就廢話不多說了,直接上代碼吧!

import psutil
import subprocess
import os
from os.path import join,getsize
import re
import time
from subprocess import PIPE
 
 
 
counter=0
filesize_last=0
def restart_process():
    haspro = 0
    all_process_name = psutil.pids();
    for pid in all_process_name:
        pro = psutil.Process(pid)
        print("process_name : ",pro.name());
        if():
            pass
        if(pro.name() == "test_tdb.exe"):
            haspro=haspro+1
            pro.kill()
            os.popen("E:/data/tdb/code/test_tdb.exe")
            break
    if(haspro==0):
        os.popen("E:/data/tdb/code/test_tdb.exe")
#            time.sleep(5)
while(counter>=0):
   filesize = getsize(r"e:\log.csv")
   if(counter>0):
        if(filesize==filesize_last):
            print("EQUAL!")
            restart_process()
            counter=0
        if(filesize!=filesize_last):
            print("NOT EQUAL!")
            counter=0
            pass
   if(counter==0):
        filesize_last = filesize
        counter=counter+1
        time.sleep(300)
 
#p = subprocess.Popen('D:/project/server/bin/Debug/test_tdb.exe', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT);
#returncode = p.poll()
#while returncode is None:
#    line = p.stdout.readline()
#    returncode = p.poll()
#    line = line.strip()
 #    print ('line : ',line);
#    print ('returncode : ',returncode);
#    if(line == b'Could not create log file: No such file or directory'):
#        pass
 
            #os.popen("D:/project/server/bin/Debug/test_tdb.exe",'r',-1)
        #os.system('D:/project/server/bin/Debug/test_tdb.exe')
        # p1=psutil.Popen(["D:/project/server/bin/Debug/test_tdb.exe"],stdout=PIPE)
#process_list = psutil.get_process_list()
#print("process_list : ",process_list);
 
#all_process_name = psutil.pids();
#print("all_process_name= ",all_process_name);
#for pid in all_process_name:
#    pro = psutil.Process(pid);
 #if(counter == 0):
        #print ('There are %.2f ' %(filesize/1024),'Kb')
#
 #        if(pro.name() == "test_tdb.exe"):
 #           counter = counter+1
 #           pro.kill();
  #           os.popen("D:/project/server/bin/Debug/test_tdb.exe")
  #          time.sleep(5);

以上這篇python psutil監(jiān)控進(jìn)程實(shí)例就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Python中更優(yōu)雅的日志記錄方案詳解

    Python中更優(yōu)雅的日志記錄方案詳解

    在Python中,一般情況下我們可能直接用自帶的logging模塊來記錄日志,但logging用起來其實(shí)并不是那么好用,其實(shí)主要還是配置較為繁瑣。本文為大家介紹了Python中更優(yōu)雅的日志記錄方案,需要的可以參考一下
    2022-06-06
  • Python的Tornado框架異步編程入門實(shí)例

    Python的Tornado框架異步編程入門實(shí)例

    這篇文章主要介紹了Python的Tornado框架異步編程入門實(shí)例,異步編程的思維與普通編程比起來有些不同,需要的朋友可以參考下
    2015-04-04
  • Python 私有函數(shù)的實(shí)例詳解

    Python 私有函數(shù)的實(shí)例詳解

    這篇文章主要介紹了Python 私有函數(shù)的實(shí)例詳解的相關(guān)資料,希望通過本文大家能掌握Python 私有函數(shù)的使用方法,需要的朋友可以參考下
    2017-09-09
  • pytorch中的model.eval()和BN層的使用

    pytorch中的model.eval()和BN層的使用

    這篇文章主要介紹了pytorch中的model.eval()和BN層的使用,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-05-05
  • Python pip 安裝與使用(安裝、更新、刪除)

    Python pip 安裝與使用(安裝、更新、刪除)

    pip 是 Python 包管理工具,該工具提供了對Python 包的查找、下載、安裝、卸載的功能,需要的朋友可以參考下
    2019-10-10
  • python數(shù)組復(fù)制拷貝的實(shí)現(xiàn)方法

    python數(shù)組復(fù)制拷貝的實(shí)現(xiàn)方法

    這篇文章主要介紹了python數(shù)組復(fù)制拷貝的實(shí)現(xiàn)方法,實(shí)例分析了Python數(shù)組傳地址與傳值兩種復(fù)制拷貝的使用技巧,需要的朋友可以參考下
    2015-06-06
  • pytest解讀fixtures之Teardown處理yield和addfinalizer方案

    pytest解讀fixtures之Teardown處理yield和addfinalizer方案

    這篇文章主要為大家介紹了pytest解讀fixtures之Teardown處理yield和addfinalizer的方案實(shí)例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-06-06
  • Python如何運(yùn)用pyaudio庫去做一個(gè)固定采樣率音頻錄制器

    Python如何運(yùn)用pyaudio庫去做一個(gè)固定采樣率音頻錄制器

    這篇文章主要介紹了Python如何運(yùn)用pyaudio庫去做一個(gè)固定采樣率音頻錄制器問題,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-05-05
  • python挖礦算力測試程序詳解

    python挖礦算力測試程序詳解

    這篇文章主要介紹了python挖礦算力測試程序詳解的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2019-07-07
  • python使用標(biāo)準(zhǔn)庫根據(jù)進(jìn)程名如何獲取進(jìn)程的pid詳解

    python使用標(biāo)準(zhǔn)庫根據(jù)進(jìn)程名如何獲取進(jìn)程的pid詳解

    Python有一套很有用的標(biāo)準(zhǔn)庫(standard library)。標(biāo)準(zhǔn)庫會隨著Python解釋器,一起安裝在你的電腦中的,所以下面這篇文章主要給大家介紹了關(guān)于python使用標(biāo)準(zhǔn)庫根據(jù)進(jìn)程名如何獲取進(jìn)程pid的相關(guān)資料,需要的朋友可以參考下。
    2017-10-10

最新評論