0

I uses a SQL Job which call the Python Script.. In some scenario I want to exit out of script without failing the job completely, but just by throwing some message. The SQL job has 3 steps such as 1. PreProcess 2. Process 3. PostProcess.. So In some situation, want to exit out of PreProcess but still want to process PostProcess.. Below is my class structure.

class Test:
   def pre_process():
      #some code
      sys.exit("exiting out of program")

   def process():
     #some code

   def post_process():
    #some code

  def run():
    try:
        pre_process()
        process()
    except Exception as e:
        raise e
    finally:
        post_process()

So the issue here is the code is exiting out but with error. But want to exit out of the program successfully. Any suggestion is helpful!

Pradeep
  • 303
  • 1
  • 5
  • 18

1 Answers1

0
raise RuntimeError("Description of the error") 

Something like this can be used.

You can also look into different loop breaking schemes of Python. Maybe this will be helpful: How to break out of multiple loops in python

Pranay
  • 498
  • 1
  • 4
  • 16