I'm developing Server Monitoring Program. I use thread coding to collect several information like cpu, mem, disk, ping etc. And it causes python.exe has stopped error.
APPCRASH
Process finished with exit code -1073741819 (0xC0000005)
And error occurs as faster as I use more threads!
Here's my code
self.thread = Thread(target=self.clntResourceGetter, args=())
self.thread.start()
def clntResourceGetter(self):
time.sleep(5)
while self.t_flag:
for client in self.clientList:
try:
stdin1, stdout1, stderr1 = self.sshListForResMon[client[0]].exec_command('''free |grep Mem |awk '{print $2" "$3" "$3}' ''')
stdin2, stdout2, stderr2 = self.sshListForResMon[client[0]].exec_command('''vmstat |tail -1 |awk '{print $15}' ''')
[...]
resourceInfoDAO = ResourceInfoDAO()
resourceInfoDAO.insertResourceInfo(tmpClient)
except Exception as e:
print(e)
time.sleep(5)
Code is simple. As shown, thread execuetes clntResourceGetter function and it runs forever. Why do thread cause python.exe stop error?
User contributions licensed under CC BY-SA 3.0