Skip to content

Use of os._exit() in RNS.exit() does not allow for proper cleanup #822

@lbatalha

Description

@lbatalha

As per python docs for os._exit():

Exit the process with status n, without calling cleanup handlers, flushing stdio buffers, etc.

This can cause problems in certain scenarios, for example when the program makes use of multiprocessing libraries.

A good example is when using concurrent.futures, using any of the Pools (ProcessPoolExecutor and ThreadPoolExecutor) causes python to transparently launch a background process for multiprocessing.resource_tracker, when the program is exiting in an unclean way this causes warnings:
UserWarning: resource_tracker: There appear to be 5 leaked semaphore objects to clean up at shutdown

Presumably this does not actually cause any problems, except that you cannot squash these warnings in any way other than passing -W ignore:semaphore_tracker:UserWarning to the python interpreter (handling it with modules does not work)

In my testing, replacing that call with the the regular sys.exit() method completely resolves this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions