Kapacitor - udf Timeout

Hi,
I am trying to get data from InfluxDB inside a kapcitor udf written in Python using InfluxDBClient. I am able to get data in case the size is very small like 2000 records, but as soon as the size of data goes beyond that it starts failing with below error message:
ts=2018-10-22T11:19:32.535Z lvl=error msg=“encountered error” service=kapacitor task_master=main task=batch_task1 node=func2 err="keepalive timedout, last keepalive received was: 2018-10-22 11:17:52.535771714 +0000 UTC
ts=2018-10-22T11:19:32.536Z lvl=error msg=“failed to snapshot task” service=kapacitor task_master=main task=batch_task1 err="keepalive timedout, last keepalive received was: 2018-10-22 11:17:52.535771714 +0000 UTC
I have tried changing timeouts in kapacitor.conf for udffunctions but didn’t get any success. I even tried raising the timeout to large value more than 1 hour but still it gives the same error.

Any help would be appreciated.

Thanks in advance
Tarun