Rev 2289: os._exit rather than sys.exit at top level in http://sourcefrog.net/bzr/trivial
Martin Pool
mbp at sourcefrog.net
Thu Feb 15 06:15:44 GMT 2007
At http://sourcefrog.net/bzr/trivial
------------------------------------------------------------
revno: 2289
revision-id: mbp at sourcefrog.net-20070215061543-yzyvx2fuidks9l7i
parent: pqm at pqm.ubuntu.com-20070215023751-277626e9357e8a6c
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: trivial
timestamp: Thu 2007-02-15 17:15:43 +1100
message:
os._exit rather than sys.exit at top level
somewhat faster through avoiding shutdown
and avoids bg threads whining about modules going away
modified:
bzr bzr.py-20050313053754-5485f144c7006fa6
bzrlib/transport/smart.py ssh.py-20060608202016-c25gvf1ob7ypbus6-1
=== modified file 'bzr'
--- a/bzr 2007-01-24 20:40:20 +0000
+++ b/bzr 2007-02-15 06:15:43 +0000
@@ -96,6 +96,17 @@
if profiling:
profile_imports.log_stack_info(sys.stderr)
- sys.exit(exit_val)
+
+ # By this point we really have completed everything we want to do, and
+ # there's no point doing any additional cleanup. Abruptly exiting here
+ # stops any background threads getting into trouble as code is unloaded,
+ # and it may also be slightly faster, through avoiding gc of objects that
+ # are just about to be discarded anyhow. This does mean that atexit hooks
+ # won't run but we don't use them. Also file buffers won't be flushed,
+ # but our policy is to always close files from a finally block. -- mbp 20070215
+ sys.stdout.flush()
+ sys.stderr.flush()
+ os._exit(exit_val)
+ ## sys.exit(exit_val)
else:
pass # should this give an error? - it can't be used as a lib
=== modified file 'bzrlib/transport/smart.py'
--- a/bzrlib/transport/smart.py 2006-12-18 15:34:08 +0000
+++ b/bzrlib/transport/smart.py 2007-02-15 06:15:43 +0000
@@ -867,9 +867,11 @@
def stop_background_thread(self):
self._should_terminate = True
+ # At one point we would wait to join the threads here, but it looks
+ # like they don't actually exit. So now we just leave them running
+ # and expect to terminate the process. -- mbp 20070215
# self._server_socket.close()
- # we used to join the thread, but it's not really necessary; it will
- # terminate in time
+ ## sys.stderr.write("waiting for server thread to finish...")
## self._server_thread.join()
More information about the bazaar-commits
mailing list