{"id":355,"date":"2021-08-04T18:32:35","date_gmt":"2021-08-04T10:32:35","guid":{"rendered":"https:\/\/www.heliang.net.cn\/?p=355"},"modified":"2021-08-04T18:33:30","modified_gmt":"2021-08-04T10:33:30","slug":"python-script-stuck-at-subprocess","status":"publish","type":"post","link":"https:\/\/www.heliang.net.cn\/?p=355","title":{"rendered":"Python Script stuck at subprocess"},"content":{"rendered":"\n<ul><li><strong>If running the script in verbose mode with &#8220;-v&#8221;, it stuck at<\/strong><\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>...\nIMPORT 'TOKEN' # &lt;_FROZEN_IMPORTLIB_EXTERNAL.SOURCEFILELOADER OBJECT AT 0X302C5770&gt;\nIMPORT 'TOKENIZE' # &lt;_FROZEN_IMPORTLIB_EXTERNAL.SOURCEFILELOADER OBJECT AT 0X302BE210&gt;\nIMPORT 'LINECACHE' # &lt;_FROZEN_IMPORTLIB_EXTERNAL.SOURCEFILELOADER OBJECT AT 0X302BE050&gt;\nIMPORT 'TRACEBACK' # &lt;_FROZEN_IMPORTLIB_EXTERNAL.SOURCEFILELOADER OBJECT AT 0X302B0670&gt;\nIMPORT 'THREADING' # &lt;_FROZEN_IMPORTLIB_EXTERNAL.SOURCEFILELOADER OBJECT AT 0X3029C9B0&gt;\nIMPORT 'SUBPROCESS' # &lt;_FROZEN_IMPORTLIB_EXTERNAL.SOURCEFILELOADER OBJECT AT 0X30194850&gt;\n\/OPT\/LIB\/PYTHON3.7\/PYCACHE\/_BOOTLOCALE.CPYTHON-37.PYC MATCHES \/OPT\/LIB\/PYTHON3.7\/_BOOTLOCALE.PY\nCODE OBJECT FROM '\/OPT\/LIB\/PYTHON3.7\/PYCACHE\/_BOOTLOCALE.CPYTHON-37.PYC'\nIMPORT '_BOOTLOCALE' # &lt;_FROZEN_IMPORTLIB_EXTERNAL.SOURCEFILELOADER OBJECT AT 0X30290850&gt;\n...\n<\/code><\/pre>\n\n\n\n<ul><li><strong>It stuck at below if running with &#8220;-m trace &#8211;trace&#8221;<\/strong><\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>\nsubprocess.py(876):         if not self._child_created:\nsubprocess.py(879):         if self.returncode is None:\nsubprocess.py(882):             _warn(\"subprocess %s is still running\" % self.pid,\nsubprocess.py(883):                   ResourceWarning, source=self)\nsubprocess.py(885):         self._internal_poll(_deadstate=_maxsize)\n --- modulename: subprocess, funcname: _internal_poll\nsubprocess.py(1582):             if self.returncode is None:\nsubprocess.py(1583):                 if not self._waitpid_lock.acquire(False):\nsubprocess.py(1587):                 try:\nsubprocess.py(1588):                     if self.returncode is not None:\nsubprocess.py(1590):                     pid, sts = _waitpid(self.pid, _WNOHANG)\nsubprocess.py(1591):                     if pid == self.pid:\nsubprocess.py(1604):                     self._waitpid_lock.release()\nsubprocess.py(1605):             return self.returncode\nsubprocess.py(886):         if self.returncode is None and _active is not None:\nsubprocess.py(888):             _active.append(self)\n --- modulename: latin_1, funcname: decode\n<\/code><\/pre>\n\n\n\n<p>Finally found the script includes os.popen to run a command, and that command is still being showed &#8220;ps -ef &#8221; even though the script was terminated.  Then killed the process triggered by python script, and the script works again.<\/p>\n\n\n\n<p>Hope this help.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If running the script in verbose mode with &#8220;-v&#038;#8 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[23],"tags":[],"_links":{"self":[{"href":"https:\/\/www.heliang.net.cn\/index.php?rest_route=\/wp\/v2\/posts\/355"}],"collection":[{"href":"https:\/\/www.heliang.net.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.heliang.net.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.heliang.net.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.heliang.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=355"}],"version-history":[{"count":2,"href":"https:\/\/www.heliang.net.cn\/index.php?rest_route=\/wp\/v2\/posts\/355\/revisions"}],"predecessor-version":[{"id":357,"href":"https:\/\/www.heliang.net.cn\/index.php?rest_route=\/wp\/v2\/posts\/355\/revisions\/357"}],"wp:attachment":[{"href":"https:\/\/www.heliang.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=355"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.heliang.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=355"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.heliang.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=355"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}