Heim  >  Fragen und Antworten  >  Hauptteil

linux - 如果python time.sleep在睡眠后无法唤醒,那会是什么原因呢?

我有个linux系统的主机,这个主机上开机便运行一段在正常情况下永远不会停止的python代码,其中有语句为

time.sleep(100);

在刚开机后一段时间可以经过它来控制睡眠和唤醒,但是运行大概几天的时间就唤不醒了,这会是什么原因呢?我查进程表中这个进程还在跑。

我编写的代码结构如下:

while True:
    try:
        ... some code ...
        time.sleep(100);
        ... other code ...
    except Exception,e:
        ... some code...
PHP中文网PHP中文网2742 Tage vor926

Antworte allen(4)Ich werde antworten

  • PHP中文网

    PHP中文网2017-04-17 13:52:36

    存在比如网络请求的代码,但是没有设置timeout,比如sys.setdefaulttimeout之类的,那么有可能会让程序永远卡在网络请求的地方出不来

    Antwort
    0
  • 高洛峰

    高洛峰2017-04-17 13:52:36

    会不会在sleep()前面或者后面的code阻塞了脚本的执行?或者异常Exception里已经抛了?

    Antwort
    0
  • PHP中文网

    PHP中文网2017-04-17 13:52:36

    问题找到了吗?我也遇到这样的问题了。很奇怪。

    Antwort
    0
  • PHP中文网

    PHP中文网2017-04-17 13:52:36

    建议你用strace调试一下进程,看它在干嘛.

    Antwort
    0
  • StornierenAntwort