Giter Site home page Giter Site logo

Call atexit() handlers about tasktiger HOT 2 OPEN

closeio avatar closeio commented on July 27, 2024
Call atexit() handlers

from tasktiger.

Comments (2)

thomasst avatar thomasst commented on July 27, 2024

We probably don't want to just call sys.exit() instead of os._exit() since it may have undesired side-effects (some exit handlers would be called multiple times: when the fork exits, and when TaskTiger exits).

In Python 2.7 we could:

  1. Store all the atexit._exithandlers before we fork (e.g. the length of the array – we just need to know which ones not to execute)
  2. Explicitly execute any atexit._exithandlers that were added while the task was executing
  3. Exit the task process with os._exit() the same way we do now.

There's also sys.exitfunc but we shouldn't support it because it was deprecated since version 2.4.

In Python 3.x we can't do that because atexit() is a built-in module (http://bugs.python.org/issue1680961). We could do the following in Python 3.x:

  1. After forking, from atexit import _clear and _clear()
  2. Before exiting the task, from atexit import _run_exitfuncs and _run_exitfuncs(). Or, just call sys.exit() assuming there are no other side-effects.

from tasktiger.

philfreo avatar philfreo commented on July 27, 2024

Related to #34

from tasktiger.

Related Issues (20)

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.