From simon.kiertscher at gmx.de Thu Sep 8 16:35:36 2011 From: simon.kiertscher at gmx.de (Simon Kiertscher) Date: Thu, 08 Sep 2011 16:35:36 +0200 Subject: [capi-sig] getting popen error after long term use Message-ID: <4E68D2B8.9020304@gmx.de> Hi all, I hope I post on the correct list, sorry if not. I have written a C-daemon and I use the C/Python API for calling bash commands via python using popen. My daemon seems to run without errors, but after a unknown period of time (sometimes the daemon runs a week without problems, sometimes a month) the program isn't able to run the python scripts any more. I get the following error: Exception exceptions.AttributeError: "'Popen' object has no attribute '_child_created'" in > ignored I googled the error but didn't get smarter. So I have no idea if the error is on the python site or on the c site. And I have no idea why the error occurs after a long time of run. I would think (because of the unknown time fact) there is a memory leak or something like that, what else could it be? Has anyone an idea would I could do wrong? My c calls look like that: int shutdown(const char *node_address, struct content *content) { assert(node_address != NULL); PyObject *funk, *prm, *ret; funk = PyObject_GetAttrString(content->modul, "shutdown"); if(funk == NULL) { syslog(LOG_ERR, "[MASTER] [shutdown] CANT LOAD SHUTDOWN FROM %s.PY",content->scriptname); return(EXIT_FAILURE); } prm = Py_BuildValue("(s)", node_address); if(prm == NULL) { Py_CLEAR(funk); syslog(LOG_ERR, "[MASTER] [shutdown] CANT BUILD VALUE"); return(EXIT_FAILURE); } ret = PyObject_CallObject(funk, prm); if(ret == NULL) { Py_CLEAR(funk); Py_CLEAR(ret); syslog(LOG_ERR, "[MASTER] [shutdown] CANT CALL FUNCTION OBJECT"); return(EXIT_FAILURE); } if(PyInt_AsLong(ret)!=0) { Py_CLEAR(prm); Py_CLEAR(funk); Py_CLEAR(ret); syslog(LOG_ERR, "[MASTER] [shutdown] ERROR ON PyInt_AsLong"); return(EXIT_FAILURE); } Py_CLEAR(ret); Py_CLEAR(prm); Py_CLEAR(funk); return EXIT_SUCCESS; } And my Python calls look like that: def shutdown(node_address): p = subprocess.Popen(["ipmitool","-l", "LAN", "-H",node_address,"-U", "root", "-P", config.IPMIPassword, "power", "soft"],stdout=subprocess.PIPE, stderr=subprocess.PIPE) p.communicate() return p.returncode When I kill the daemon after noticing that it can't call he functions any more, I get the following errors in addition: Exception exceptions.IndexError: 'list index out of range' in 'garbage collection' ignored Fatal Python error: unexpected exception during garbage collection I strongly hope someone has an idea about that. Sorry for the bad English. Best Regards, Simon