How to stop an infinite loop safely in Python?

后端 未结 4 1970
长发绾君心
长发绾君心 2020-12-09 11:00

I\'ve got a script that runs on a infinite loop and adds things to a database and does things that I can\'t just stop halfway through so I can\'t just press ctrl+C and stop

4条回答
  •  悲&欢浪女
    2020-12-09 11:21

    To clarify @praba230890's solution: The interrupted variable was not defined in the correct scope. It was defined in the crawl function and the handler could not reach it as a global variable, according to the definition of the handler at the root of the program.

提交回复
热议问题