2

I am trying to pickle python function which uses ctypes object to call some function.

I have created a '.so' file with my sum function which I am trying to invoke in my python code

c code

#include <stdio.h>


int sum(int a, int b) {

    return a + b;

}

use in python code

from ctypes import cdll
libsum = cdll.LoadLibrary("libsum.so")

def cal_sum(param1, param2):
    return libsum.sum(param1, param2)

When I try to pickle the cal_sum function using

out = open("/tmp/abc", "wb")
cloudpickle.dump(cal_sum, out)
out.close()

I am getting below error

TypeError: can't pickle getset_descriptor objects.

Is there any way we can pickle such function

0 Answers0