Skip to content
Browse files

MB-6867: Use os._exit() to handle exit

Due to unknown threading issue, python process won't exit using
sys.exit() even though all tasks are done. os._exit() will force
process to exit

Change-Id: If60952945a24256f39d0383c8ddcb3f29dedc537
Reviewed-on: http://review.couchbase.org/21555
Tested-by: Bin Cui <bin.cui@gmail.com>
Reviewed-by: Pavel Paulau <pavel.paulau@gmail.com>
  • Loading branch information...
1 parent 41f02a1 commit bcbe7d3a67e822d56547de563da2b9d4ce808130 @bcui6611 bcui6611 committed with Farshid Ghods Oct 11, 2012
Showing with 13 additions and 5 deletions.
  1. +1 −1 cbbackup
  2. +1 −1 cbrestore
  3. +1 −1 cbtransfer
  4. +2 −2 cbworkloadgen
  5. +8 −0 pump_transfer.py
View
2 cbbackup
@@ -9,4 +9,4 @@ import pump_transfer
import sys
if __name__ == '__main__':
- sys.exit(pump_transfer.Backup().main(sys.argv))
+ pump_transfer.exit_handler(pump_transfer.Backup().main(sys.argv))
View
2 cbrestore
@@ -9,4 +9,4 @@ import pump_transfer
import sys
if __name__ == '__main__':
- sys.exit(pump_transfer.Restore().main(sys.argv))
+ pump_transfer.exit_handler(pump_transfer.Restore().main(sys.argv))
View
2 cbtransfer
@@ -30,4 +30,4 @@ if __name__ == '__main__':
bin_dir = os.path.join(mydir, '..')
path = [mydir, bin_dir, os.environ['PATH']]
os.environ['PATH'] = ';'.join(path)
- sys.exit(pump_transfer.Transfer().main(sys.argv))
+ pump_transfer.exit_handler(pump_transfer.Transfer().main(sys.argv))
View
4 cbworkloadgen
@@ -43,7 +43,7 @@ class WorkloadGen(pump_transfer.Transfer):
for i in range(v[1]):
local_args.append(v[0])
- pump_transfer.Transfer.main(self, local_args)
+ return pump_transfer.Transfer.main(self, local_args)
def opt_construct(self, argv):
gen_opts = {"ratio_sets": "ratio-sets",
@@ -145,4 +145,4 @@ class WorkloadGen(pump_transfer.Transfer):
return pump_gen.GenSource, pump.PumpingStation.find_handler(opts, sink, pump_transfer.SINKS)
if __name__ == '__main__':
- sys.exit(WorkloadGen().main(sys.argv))
+ pump_transfer.exit_handler(WorkloadGen().main(sys.argv))
View
8 pump_transfer.py
@@ -5,6 +5,7 @@
import optparse
import sys
import threading
+import os
import pump
import pump_bfd
@@ -30,6 +31,13 @@
if status is None:
sys.exit("Error: could not import sqlite3 module")
+def exit_handler(err):
+ if err:
+ sys.stderr.write(err + "\n")
+ os._exit(1)
+ else:
+ os._exit(0)
+
class Transfer:
"""Base class for 2.0 Backup/Restore/Transfer."""

0 comments on commit bcbe7d3

Please sign in to comment.
Something went wrong with that request. Please try again.