Giter Site home page Giter Site logo

graceful_exit's Introduction

需要说明的是:

如果某个进程接受 kill pid,必须在该进程函数的最外层捕获: except GracefulExitException,

同时该进程函数内部调用捕获了 except Excetion,则必须在之前捕获GracefulExitException,

即:(2) 必须在(3)之前。否则同时去掉(2)和(3)。


    def do_some_func():
      try:
          time.sleep(10)
 
            blablabla
 
        (1) except SomeError:
            # 捕获特定的异常
            pass
 
        (2) except GracefulExitException:
            # 接收 kill pid
            pass
 
        (3) except:  # 不建议捕获默认异常, 否则必须在此之前捕获:GracefulExitException
            pass
 
 
 
    def some_process_main(gee):
 
        try:
 
            while not gee.is_stop():
                do_some_func()
 
        except GracefulExitException:
            # 接收到了 kill pid, 设置中止循环
            gee.notify_stop()
            pass
        except:
            pass

graceful_exit's People

Watchers

Yang Guang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.