Python脚本将空值返回给php

I am using python for creating excel file. i am calling python script from my php code. php:

$result = exec('..'.DIRECTORY_SEPARATOR.'pythonsample'.DIRECTORY_SEPARATOR.'xlswriterSample.py 2>&1',$output,$returnVal);

python:

state = "Processing...."
print state;
st = time.time();

#here code for creating excel file

et = time.time();
dif = et - st;
print dif;
print "created successfully"

it works fine when creating small excel files(processing time less then 1 min). it returns all the printed value in python.

But when attempting large file(processing time more then 2 min) it does not return any value to php. it returns null value. but excel file created successfully.

how to get return value from python at this scenario?

note: i tried shell_exec() function also. it also returns null for long processing