Changeset 295
- Timestamp:
- Aug 3, 2011, 9:12:16 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-kernel/service_internal_python.c
r114 r295 74 74 free(pythonpath); 75 75 76 PyThreadState *mainstate; 77 PyEval_InitThreads(); 76 78 Py_Initialize(); 79 mainstate = PyThreadState_Swap(NULL); 80 PyEval_ReleaseLock(); 81 PyGILState_STATE gstate; 82 gstate = PyGILState_Ensure(); 77 83 PyObject *pName, *pModule, *pFunc; 78 84 tmp=getMap(s->content,"serviceProvider"); … … 119 125 dumpMaps(outputs); 120 126 #endif 121 Py_DECREF(arg1);122 Py_DECREF(arg2);123 Py_DECREF(arg3);124 Py_DECREF(pArgs);125 Py_DECREF(pValue);126 Py_XDECREF(pFunc);127 Py_DECREF(pModule);128 127 }else{ 129 128 PyObject *ptype,*pvalue, *ptraceback; … … 159 158 addToMap(err,"code","NoApplicableCode"); 160 159 printExceptionReportResponse(m,err); 161 Py_DECREF(arg1); 162 Py_DECREF(arg2); 163 Py_DECREF(arg3); 164 Py_XDECREF(pFunc); 165 Py_DECREF(pArgs); 166 Py_DECREF(pModule); 167 Py_DECREF(ptraceback); 168 Py_DECREF(ptype); 169 Py_DECREF(pValue); 170 #if not(defined(macintosh)) && not(defined(__MACH__) && defined(__APPLE__)) 171 Py_Finalize(); 172 #endif 173 exit(-1); 160 res=-1; 174 161 } 175 162 } 176 163 else{ 177 164 char tmpS[1024]; 178 sprintf(tmpS, "Cannot find the %s function in tthe %s file.\n", s->name, tmp->value);165 sprintf(tmpS, "Cannot find the %s function in the %s file.\n", s->name, tmp->value); 179 166 map* tmps=createMap("text",tmpS); 180 167 printExceptionReportResponse(m,tmps); 181 Py_XDECREF(pFunc); 182 Py_DECREF(pModule); 183 exit(-1); 168 res=-1; 184 169 } 185 170 } else{ … … 190 175 if (PyErr_Occurred()) 191 176 PyErr_Print(); 192 exit(-1); 177 PyErr_Clear(); 178 res=-1; 179 //exit(-1); 193 180 } 194 #if not(defined(macintosh)) && not(defined(__MACH__) && defined(__APPLE__)) 181 PyGILState_Release(gstate); 182 PyEval_AcquireLock(); 183 PyThreadState_Swap(mainstate); 195 184 Py_Finalize(); 196 #endif197 185 return res; 198 186 } … … 202 190 maps* tmp=t; 203 191 while(tmp!=NULL){ 204 PyObject* subc=(PyObject*)PyDict_FromMap(tmp->content); 205 if(PyDict_SetItem(res,PyString_FromString(tmp->name),subc)<0){ 206 fprintf(stderr,"Unable to parse params..."); 207 exit(1); 208 } 209 Py_DECREF(subc); 192 PyObject* value=(PyObject*)PyDict_FromMap(tmp->content); 193 PyObject* name=PyString_FromString(tmp->name); 194 if(PyDict_SetItem(res,name,value)<0){ 195 fprintf(stderr,"Unable to set map value ..."); 196 return NULL; 197 } 198 Py_DECREF(name); 210 199 tmp=tmp->next; 211 200 } … … 223 212 PyObject* value=PyString_FromStringAndSize(tmp->value,atoi(size->value)); 224 213 if(PyDict_SetItem(res,name,value)<0){ 225 fprintf(stderr,"Unable to parse params..."); 226 Py_DECREF(value); 227 exit(1); 214 fprintf(stderr,"Unable to set key value pair..."); 215 return NULL; 228 216 } 229 Py_DECREF(value);230 217 } 231 218 else{ 232 219 PyObject* value=PyString_FromString(tmp->value); 233 220 if(PyDict_SetItem(res,name,value)<0){ 234 fprintf(stderr,"Unable to parse params..."); 235 Py_DECREF(value); 236 exit(1); 221 fprintf(stderr,"Unable to set key value pair..."); 222 return NULL; 237 223 } 238 Py_DECREF(value);239 224 } 240 225 } … … 242 227 PyObject* value=PyString_FromString(tmp->value); 243 228 if(PyDict_SetItem(res,name,value)<0){ 244 fprintf(stderr,"Unable to parse params..."); 245 Py_DECREF(value); 246 exit(1); 247 } 248 Py_DECREF(value); 229 fprintf(stderr,"Unable to set key value pair..."); 230 return NULL; 231 } 249 232 } 250 233 Py_DECREF(name); … … 272 255 cursor=(maps*)malloc(MAPS_SIZE); 273 256 cursor->name=PyString_AsString(key); 274 #ifdef DEBUG275 dumpMap(mapFromPyDict((PyDictObject*)value));276 #endif277 257 cursor->content=mapFromPyDict((PyDictObject*)value); 258 #ifdef DEBUG 259 dumpMap(cursor->content); 260 #endif 278 261 cursor->next=NULL; 279 262 if(res==NULL) … … 284 267 free(cursor->content); 285 268 free(cursor); 286 Py_DECREF(value);287 Py_DECREF(key);288 269 #ifdef DEBUG 289 270 dumpMaps(res); … … 291 272 #endif 292 273 } 293 Py_DECREF(list);294 274 return res; 295 275 } … … 330 310 res=createMap(PyString_AsString(key),PyString_AsString(value)); 331 311 } 332 Py_DECREF(key); 333 } 334 Py_DECREF(list); 312 } 335 313 return res; 336 314 }
Note: See TracChangeset
for help on using the changeset viewer.