捕捉一个python应用程序退出之前 [英] Catching a python app before it exits

查看:452
本文介绍了捕捉一个python应用程序退出之前的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个python应用程序,应该是非常long-lived,但有时该过程只是消失,我不知道为什么。当这种情况发生时,没有什么记录,所以我有点失落。

I have a python app which is supposed to be very long-lived, but sometimes the process just disappears and I don't know why. Nothing gets logged when this happens, so I'm at a bit of a loss.

在代码中有一些方法可以挂钩到一个退出事件,或者一些其他方式让我的代码在进程退出之前运行?我想记录内存结构的状态,以更好地了解发生了什么。

Is there some way in code I can hook in to an exit event, or some other way to get some of my code to run just before the process quits? I'd like to log the state of memory structures to better understand what's going on.

推荐答案

atexit 发音为at exit。第一次我读取这个函数名,我读它作为一个texit,这不使几乎更有意义。

这篇关于捕捉一个python应用程序退出之前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆