Invoke Python Method: Pipe is broken

Hi,
I’m trying to load a python script in my project when I called “Invoke python method” I’m getting pipe is broken error. Could someone help me on this

@VC365

Have a look below thread.

Hi @VC365,

Pipe is broken is a very abstract error in .net and C# and with minimal root cause. I have wasted a lot of time trying to find out why this happens without a concrete answer in the forums or in stackoverflow.

In my view, the amount of data being sent from one activity to another or one workflow to another throws “Pipe is broken.” error in UiPath. I suspect that your python code returns an object (json, og other object from python to .net) which is of a large size.

What is large?
In my tests on datatables, I found that if the datatable has more than 8000 rows and you are trying to send this to another workflow to process, then there are more chances for the “Pipe is broken” error in UiPath. In my case, I faced this error while finding unique values in a column within a large datatable (>8000 rows) and passed the datatable to another workflow. My solution was to not send the datatable to another workflow, but to process it right there within the process.

My suggestion:
Try/test by reducing the size of the object returned from Python by slicing the returned value. If that does not work please try and convert your return object to a json string.

In UiPath you can easily deserialize the return string from Python to get the json object and do any manipulations on it. Please refer this post to know how to do this from the python code and integrate this within UiPath: How to use permuation and combination in excel uipath - Help - UiPath Community Forum

Hope this gives you some ideas. Goodluck!

@jeevith thanks for the reply I have got to know the reason behind it my script takes a PDF file as input and converts checkboxes within it to yes and no and then coverts back to PDFS using some packages like tensonflow etc. May i know what can be the size to avoid pipe is broken error. BTW my script is not returning anything it just performs some actions on file and then places in specified path.
FYI here is one more query I posted related to my issue which was not resolved so I had to choose this option to convert them
How do I read a checkbox from a PDF using Document understanding framework.

Hi @VC365,

Interesting. So nothing is actually being passed as object to UiPath from the python script.

Ok can you tell us what are you returning from the python function? Would help if you paste your function’s code here.

def something(input):
   return  ??

If you are just returning a flag, it is interesting to see the Pipe is broken error occur in UiPath

@jeevith here is my main method
def main(*args):
start_time = datetime.now()

cbs = CheckBoxSolver(template_path,input_pdf_path,output_pdf_directory,model_path)
cbs.convert_pdf_to_images()
cbs.replace_checkboxes_and_save_images()
cbs.write_to_pdf()

end_time = datetime.now()

print('Duration: {}'.format(end_time - start_time))

#configuration

output_pdf_directory = “./output”
model_path = r’./model/checkbox_classifier_model.hdf5’
template_path = r’./templates’

if name == “main”:
parser = argparse.ArgumentParser()
parser.add_argument("–file_path",help=‘Pdf Input File Path’)

args = parser.parse_args()

if args.file_path:
    input_pdf_path = args.file_path
    main(template_path,input_pdf_path,output_pdf_directory,model_path)
else:
    print("Pdf Input File Path Required...")