Jython evaluator script doesn't stop even after stopping the pipeline.

asked 2020-07-09 07:54:26 -0500

Vikas Sharma gravatar image

updated 2020-07-09 11:09:35 -0500

iamontheinet gravatar image

Hi,

I have written a short script in Jython evaluator to handle error based upon the response code of my API call. The script executes infinitely if any exception occurs, i have found a solution by using break in the catch block. I have a question that even while testing my script by mistake it went on an infinite execution and i had an exception of "Array index out of range". If i stop the pipeline manually usually it should stop processing the script but still i can see the logs of execution flowing. Below is the sample script of Jython evaluator :

import sys
sys.path.append('/usr/lib/python2.7/site-packages')
import requests
import json
i=0
while i < len(records):
 try:
   data1=json.dumps(records[i].value)
   response=requests.post("<MyUrl>",headers={'Content-Type' : 'application/json'},data=data1)
   log.info("Responses: "+str(response.status_code))

   i=i+1 
   if(response.status_code==200):
         log.info("Successfully connected")

   if(response.status_code==400):
         log.info(str(response.reason))

   if(response.status_code>=500):
         time.sleep(5)
         log.info("trying to reconnect after 5 second")
         i=i-1

   except Exception as e:
    log.info(":::Exception:::"+str(e))

Need your suggestion on how to stop the pipeline without restarting the StreamSets because it consumes all of my memory.

edit retag flag offensive close merge delete