Python Script stuck at subprocess

Python Script stuck at subprocess

  • If running the script in verbose mode with “-v”, it stuck at
...
IMPORT 'TOKEN' # <_FROZEN_IMPORTLIB_EXTERNAL.SOURCEFILELOADER OBJECT AT 0X302C5770>
IMPORT 'TOKENIZE' # <_FROZEN_IMPORTLIB_EXTERNAL.SOURCEFILELOADER OBJECT AT 0X302BE210>
IMPORT 'LINECACHE' # <_FROZEN_IMPORTLIB_EXTERNAL.SOURCEFILELOADER OBJECT AT 0X302BE050>
IMPORT 'TRACEBACK' # <_FROZEN_IMPORTLIB_EXTERNAL.SOURCEFILELOADER OBJECT AT 0X302B0670>
IMPORT 'THREADING' # <_FROZEN_IMPORTLIB_EXTERNAL.SOURCEFILELOADER OBJECT AT 0X3029C9B0>
IMPORT 'SUBPROCESS' # <_FROZEN_IMPORTLIB_EXTERNAL.SOURCEFILELOADER OBJECT AT 0X30194850>
/OPT/LIB/PYTHON3.7/PYCACHE/_BOOTLOCALE.CPYTHON-37.PYC MATCHES /OPT/LIB/PYTHON3.7/_BOOTLOCALE.PY
CODE OBJECT FROM '/OPT/LIB/PYTHON3.7/PYCACHE/_BOOTLOCALE.CPYTHON-37.PYC'
IMPORT '_BOOTLOCALE' # <_FROZEN_IMPORTLIB_EXTERNAL.SOURCEFILELOADER OBJECT AT 0X30290850>
...
  • It stuck at below if running with “-m trace –trace”

subprocess.py(876):         if not self._child_created:
subprocess.py(879):         if self.returncode is None:
subprocess.py(882):             _warn("subprocess %s is still running" % self.pid,
subprocess.py(883):                   ResourceWarning, source=self)
subprocess.py(885):         self._internal_poll(_deadstate=_maxsize)
 --- modulename: subprocess, funcname: _internal_poll
subprocess.py(1582):             if self.returncode is None:
subprocess.py(1583):                 if not self._waitpid_lock.acquire(False):
subprocess.py(1587):                 try:
subprocess.py(1588):                     if self.returncode is not None:
subprocess.py(1590):                     pid, sts = _waitpid(self.pid, _WNOHANG)
subprocess.py(1591):                     if pid == self.pid:
subprocess.py(1604):                     self._waitpid_lock.release()
subprocess.py(1605):             return self.returncode
subprocess.py(886):         if self.returncode is None and _active is not None:
subprocess.py(888):             _active.append(self)
 --- modulename: latin_1, funcname: decode

Finally found the script includes os.popen to run a command, and that command is still being showed “ps -ef ” even though the script was terminated. Then killed the process triggered by python script, and the script works again.

Hope this help.

留下回复