Home  >  Q&A  >  body text

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 days ago935

reply all(4)I'll reply

  • PHP中文网

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

    There is code such as network request, but no timeout is set, such as sys.setdefaulttimeout, etc., then the program may be stuck in the network request place forever and cannot get out

    reply
    0
  • 高洛峰

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

    Will the code before or after sleep() block the execution of the script? Or has it been thrown in the Exception?

    reply
    0
  • PHP中文网

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

    Did you find the problem? I've also encountered this problem. Very strange.

    reply
    0
  • PHP中文网

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

    It is recommended that you use strace to debug the process to see what it is doing.

    reply
    0
  • Cancelreply