server/process/daemonize: Use sys.exit(), not os._exit() for server
Quoted 32 lines · Richard Purdie via lists.openembedded.org
By using
os._exit()in the server, we confuse python programmers no end since atexit calls, along with threading cleanup calls are skipped. We're careful about the environment the server is created within so we should be able to usesys.exit()here and have things behave as the python devs intend.Signed-off-by Richard Purdie <[email protected]>--- lib/bb/daemonize.py | 4 +--- lib/bb/server/process.py | 1 + 2 files changed, 2 insertions(+), 3 deletions(-)lib/bb/daemonize.py +1
-3@@ -89,9 +89,7 @@ def createDaemon(function, logfile): traceback.print_exc() finally: bb.event.print_ui_queue() - # os._exit() doesn't flush open files like os.exit() does. Manually flush - # stdout and stderr so that any logging output will be seen, particularly + # Manually flush stdout and stderr so that any logging output will be seen, particularly # exception tracebacks. sys.stdout.flush() sys.stderr.flush() - os._exit(0)lib/bb/server/process.py +0
-0
lib/bb/server/process.py class BitBakeServer(object): · line 498
Quoted 7 lines
lib/bb/server/process.py +1
-0@@ -492,6 +492,7 @@ class BitBakeServer(object): # Flush any ,essages/errors to the logfile before exit sys.stdout.flush() sys.stderr.flush() + sys.exit(0) def connectProcessServer(sockname, featureset): # Connect to socket
For the archives, we can't merge this since it allows SystemExit to be seen in the parent process, e.g. the selftests when under unittest.
Cheers,
Richard