我有一些使用Pyunpack的简单代码。
from pyunpack import Archive
import os.path
Archive(thing).extractall(os.path.dirname(thing))
thing
是我试图提取的7z文件的路径。
当我运行代码时,它会卡住。运行python -m trace --trace mycode.py
显示代码卡在subprocess.py(476): return func(*args)
我不知道为什么会这样或如何调查。有什么建议吗?
更多信息如下:
tempfile.py(233): names = _get_candidate_names()
--- modulename: tempfile, funcname: _get_candidate_names
tempfile.py(220): if _name_sequence is None:
tempfile.py(221): _once_lock.acquire()
tempfile.py(222): try:
tempfile.py(223): if _name_sequence is None:
tempfile.py(224): _name_sequence = _RandomNameSequence()
--- modulename: tempfile, funcname: __init__
tempfile.py(121): self.mutex = _allocate_lock()
tempfile.py(122): self.normcase = _os.path.normcase
tempfile.py(226): _once_lock.release()
tempfile.py(227): return _name_sequence
tempfile.py(235): for seq in xrange(TMP_MAX):
tempfile.py(236): name = names.next()
--- modulename: tempfile, funcname: next
tempfile.py(136): m = self.mutex
tempfile.py(137): c = self.characters
tempfile.py(138): choose = self.rng.choice
--- modulename: tempfile, funcname: rng
tempfile.py(126): cur_pid = _os.getpid()
tempfile.py(127): if cur_pid != getattr(self, '_rng_pid', None):
tempfile.py(128): self._rng = _Random()
--- modulename: random, funcname: __init__
random.py(97): self.seed(x)
--- modulename: random, funcname: seed
random.py(109): if a is None:
random.py(110): try:
random.py(111): a = long(_hexlify(_urandom(32)), 16)
random.py(116): super(Random, self).seed(a)
random.py(117): self.gauss_next = None
random.py(98): self.gauss_next = None
tempfile.py(129): self._rng_pid = cur_pid
tempfile.py(130): return self._rng
tempfile.py(140): m.acquire()
tempfile.py(141): try:
tempfile.py(142): letters = [choose(c) for dummy in "123456"]
--- modulename: random, funcname: choice
random.py(273): return seq[int(self.random() * len(seq))] # raises IndexError if seq is empty
tempfile.py(142): letters = [choose(c) for dummy in "123456"]
--- modulename: random, funcname: choice
random.py(273): return seq[int(self.random() * len(seq))] # raises IndexError if seq is empty
tempfile.py(142): letters = [choose(c) for dummy in "123456"]
--- modulename: random, funcname: choice
random.py(273): return seq[int(self.random() * len(seq))] # raises IndexError if seq is empty
tempfile.py(142): letters = [choose(c) for dummy in "123456"]
--- modulename: random, funcname: choice
random.py(273): return seq[int(self.random() * len(seq))] # raises IndexError if seq is empty
tempfile.py(142): letters = [choose(c) for dummy in "123456"]
--- modulename: random, funcname: choice
random.py(273): return seq[int(self.random() * len(seq))] # raises IndexError if seq is empty
tempfile.py(142): letters = [choose(c) for dummy in "123456"]
--- modulename: random, funcname: choice
random.py(273): return seq[int(self.random() * len(seq))] # raises IndexError if seq is empty
tempfile.py(142): letters = [choose(c) for dummy in "123456"]
tempfile.py(144): m.release()
tempfile.py(146): return self.normcase(''.join(letters))
--- modulename: posixpath, funcname: normcase
posixpath.py(53): return s
tempfile.py(237): file = _os.path.join(dir, pre + name + suf)
--- modulename: posixpath, funcname: join
posixpath.py(73): path = a
posixpath.py(74): for b in p:
posixpath.py(75): if b.startswith('/'):
posixpath.py(77): elif path == '' or path.endswith('/'):
posixpath.py(80): path += '/' + b
posixpath.py(74): for b in p:
posixpath.py(81): return path
tempfile.py(238): try:
tempfile.py(239): fd = _os.open(file, flags, 0600)
tempfile.py(240): _set_cloexec(fd)
--- modulename: tempfile, funcname: _set_cloexec
tempfile.py(49): try:
tempfile.py(50): flags = _fcntl.fcntl(fd, _fcntl.F_GETFD, 0)
tempfile.py(55): flags |= _fcntl.FD_CLOEXEC
tempfile.py(56): _fcntl.fcntl(fd, _fcntl.F_SETFD, flags)
tempfile.py(241): return (fd, _os.path.abspath(file))
--- modulename: posixpath, funcname: abspath
posixpath.py(367): if not isabs(path):
--- modulename: posixpath, funcname: isabs
posixpath.py(61): return s.startswith('/')
posixpath.py(373): return normpath(path)
--- modulename: posixpath, funcname: normpath
posixpath.py(339): slash, dot = (u'/', u'.') if isinstance(path, _unicode) else ('/', '.')
posixpath.py(340): if path == '':
posixpath.py(342): initial_slashes = path.startswith('/')
posixpath.py(345): if (initial_slashes and
posixpath.py(346): path.startswith('//') and not path.startswith('///')):
posixpath.py(348): comps = path.split('/')
posixpath.py(349): new_comps = []
posixpath.py(350): for comp in comps:
posixpath.py(351): if comp in ('', '.'):
posixpath.py(352): continue
posixpath.py(350): for comp in comps:
posixpath.py(351): if comp in ('', '.'):
posixpath.py(353): if (comp != '..' or (not initial_slashes and not new_comps) or
posixpath.py(355): new_comps.append(comp)
posixpath.py(350): for comp in comps:
posixpath.py(351): if comp in ('', '.'):
posixpath.py(353): if (comp != '..' or (not initial_slashes and not new_comps) or
posixpath.py(355): new_comps.append(comp)
posixpath.py(350): for comp in comps:
posixpath.py(358): comps = new_comps
posixpath.py(359): path = slash.join(comps)
posixpath.py(360): if initial_slashes:
posixpath.py(361): path = slash*initial_slashes + path
posixpath.py(362): return path or dot
tempfile.py(494): try:
tempfile.py(495): _os.unlink(name)
tempfile.py(496): return _os.fdopen(fd, mode, bufsize)
__init__.py(210): self._stderr_file = tempfile.TemporaryFile(prefix='stderr_')
--- modulename: tempfile, funcname: TemporaryFile
tempfile.py(485): if dir is None:
tempfile.py(486): dir = gettempdir()
--- modulename: tempfile, funcname: gettempdir
tempfile.py(265): if tempdir is None:
tempfile.py(272): return tempdir
tempfile.py(488): if 'b' in mode:
tempfile.py(489): flags = _bin_openflags
tempfile.py(493): (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags)
--- modulename: tempfile, funcname: _mkstemp_inner
tempfile.py(233): names = _get_candidate_names()
--- modulename: tempfile, funcname: _get_candidate_names
tempfile.py(220): if _name_sequence is None:
tempfile.py(227): return _name_sequence
tempfile.py(235): for seq in xrange(TMP_MAX):
tempfile.py(236): name = names.next()
--- modulename: tempfile, funcname: next
tempfile.py(136): m = self.mutex
tempfile.py(137): c = self.characters
tempfile.py(138): choose = self.rng.choice
--- modulename: tempfile, funcname: rng
tempfile.py(126): cur_pid = _os.getpid()
tempfile.py(127): if cur_pid != getattr(self, '_rng_pid', None):
tempfile.py(130): return self._rng
tempfile.py(140): m.acquire()
tempfile.py(141): try:
tempfile.py(142): letters = [choose(c) for dummy in "123456"]
--- modulename: random, funcname: choice
random.py(273): return seq[int(self.random() * len(seq))] # raises IndexError if seq is empty
tempfile.py(142): letters = [choose(c) for dummy in "123456"]
--- modulename: random, funcname: choice
random.py(273): return seq[int(self.random() * len(seq))] # raises IndexError if seq is empty
tempfile.py(142): letters = [choose(c) for dummy in "123456"]
--- modulename: random, funcname: choice
random.py(273): return seq[int(self.random() * len(seq))] # raises IndexError if seq is empty
tempfile.py(142): letters = [choose(c) for dummy in "123456"]
--- modulename: random, funcname: choice
random.py(273): return seq[int(self.random() * len(seq))] # raises IndexError if seq is empty
tempfile.py(142): letters = [choose(c) for dummy in "123456"]
--- modulename: random, funcname: choice
random.py(273): return seq[int(self.random() * len(seq))] # raises IndexError if seq is empty
tempfile.py(142): letters = [choose(c) for dummy in "123456"]
--- modulename: random, funcname: choice
random.py(273): return seq[int(self.random() * len(seq))] # raises IndexError if seq is empty
tempfile.py(142): letters = [choose(c) for dummy in "123456"]
tempfile.py(144): m.release()
tempfile.py(146): return self.normcase(''.join(letters))
--- modulename: posixpath, funcname: normcase
posixpath.py(53): return s
tempfile.py(237): file = _os.path.join(dir, pre + name + suf)
--- modulename: posixpath, funcname: join
posixpath.py(73): path = a
posixpath.py(74): for b in p:
posixpath.py(75): if b.startswith('/'):
posixpath.py(77): elif path == '' or path.endswith('/'):
posixpath.py(80): path += '/' + b
posixpath.py(74): for b in p:
posixpath.py(81): return path
tempfile.py(238): try:
tempfile.py(239): fd = _os.open(file, flags, 0600)
tempfile.py(240): _set_cloexec(fd)
--- modulename: tempfile, funcname: _set_cloexec
tempfile.py(49): try:
tempfile.py(50): flags = _fcntl.fcntl(fd, _fcntl.F_GETFD, 0)
tempfile.py(55): flags |= _fcntl.FD_CLOEXEC
tempfile.py(56): _fcntl.fcntl(fd, _fcntl.F_SETFD, flags)
tempfile.py(241): return (fd, _os.path.abspath(file))
--- modulename: posixpath, funcname: abspath
posixpath.py(367): if not isabs(path):
--- modulename: posixpath, funcname: isabs
posixpath.py(61): return s.startswith('/')
posixpath.py(373): return normpath(path)
--- modulename: posixpath, funcname: normpath
posixpath.py(339): slash, dot = (u'/', u'.') if isinstance(path, _unicode) else ('/', '.')
posixpath.py(340): if path == '':
posixpath.py(342): initial_slashes = path.startswith('/')
posixpath.py(345): if (initial_slashes and
posixpath.py(346): path.startswith('//') and not path.startswith('///')):
posixpath.py(348): comps = path.split('/')
posixpath.py(349): new_comps = []
posixpath.py(350): for comp in comps:
posixpath.py(351): if comp in ('', '.'):
posixpath.py(352): continue
posixpath.py(350): for comp in comps:
posixpath.py(351): if comp in ('', '.'):
posixpath.py(353): if (comp != '..' or (not initial_slashes and not new_comps) or
posixpath.py(355): new_comps.append(comp)
posixpath.py(350): for comp in comps:
posixpath.py(351): if comp in ('', '.'):
posixpath.py(353): if (comp != '..' or (not initial_slashes and not new_comps) or
posixpath.py(355): new_comps.append(comp)
posixpath.py(350): for comp in comps:
posixpath.py(358): comps = new_comps
posixpath.py(359): path = slash.join(comps)
posixpath.py(360): if initial_slashes:
posixpath.py(361): path = slash*initial_slashes + path
posixpath.py(362): return path or dot
tempfile.py(494): try:
tempfile.py(495): _os.unlink(name)
tempfile.py(496): return _os.fdopen(fd, mode, bufsize)
__init__.py(211): stdout = self._stdout_file
__init__.py(212): stderr = self._stderr_file
__init__.py(218): cmd = list(map(uniencode, self.cmd))
--- modulename: unicodeutil, funcname: uniencode
unicodeutil.py(49): if PY3:
unicodeutil.py(53): if isinstance(s, unicode):
unicodeutil.py(55): return s
--- modulename: unicodeutil, funcname: uniencode
unicodeutil.py(49): if PY3:
unicodeutil.py(53): if isinstance(s, unicode):
unicodeutil.py(55): return s
--- modulename: unicodeutil, funcname: uniencode
unicodeutil.py(49): if PY3:
unicodeutil.py(53): if isinstance(s, unicode):
unicodeutil.py(55): return s
--- modulename: unicodeutil, funcname: uniencode
unicodeutil.py(49): if PY3:
unicodeutil.py(53): if isinstance(s, unicode):
unicodeutil.py(54): s = s.encode('utf-8')
unicodeutil.py(55): return s
--- modulename: unicodeutil, funcname: uniencode
unicodeutil.py(49): if PY3:
unicodeutil.py(53): if isinstance(s, unicode):
unicodeutil.py(54): s = s.encode('utf-8')
unicodeutil.py(55): return s
__init__.py(220): try:
__init__.py(221): self.popen = subprocess.Popen(cmd,
__init__.py(222): stdout=stdout,
__init__.py(223): stderr=stderr,
__init__.py(224): cwd=self.cwd,
__init__.py(225): env=self.env,
--- modulename: subprocess, funcname: __init__
subprocess.py(656): _cleanup()
--- modulename: subprocess, funcname: _cleanup
subprocess.py(459): for inst in _active[:]:
subprocess.py(658): if not isinstance(bufsize, (int, long)):
subprocess.py(661): if mswindows:
subprocess.py(671): if startupinfo is not None:
subprocess.py(674): if creationflags != 0:
subprocess.py(678): self.stdin = None
subprocess.py(679): self.stdout = None
subprocess.py(680): self.stderr = None
subprocess.py(681): self.pid = None
subprocess.py(682): self.returncode = None
subprocess.py(683): self.universal_newlines = universal_newlines
subprocess.py(702): errread, errwrite), to_close = self._get_handles(stdin, stdout, stderr)
--- modulename: subprocess, funcname: _get_handles
subprocess.py(1103): to_close = set()
subprocess.py(1104): p2cread, p2cwrite = None, None
subprocess.py(1105): c2pread, c2pwrite = None, None
subprocess.py(1106): errread, errwrite = None, None
subprocess.py(1108): if stdin is None:
subprocess.py(1109): pass
subprocess.py(1119): if stdout is None:
subprocess.py(1121): elif stdout == PIPE:
subprocess.py(1124): elif isinstance(stdout, int):
subprocess.py(1128): c2pwrite = stdout.fileno()
subprocess.py(1130): if stderr is None:
subprocess.py(1132): elif stderr == PIPE:
subprocess.py(1135): elif stderr == STDOUT:
subprocess.py(1137): elif isinstance(stderr, int):
subprocess.py(1141): errwrite = stderr.fileno()
subprocess.py(1143): return (p2cread, p2cwrite,
subprocess.py(1144): c2pread, c2pwrite,
subprocess.py(1145): errread, errwrite), to_close
subprocess.py(704): try:
subprocess.py(705): self._execute_child(args, executable, preexec_fn, close_fds,
subprocess.py(706): cwd, env, universal_newlines,
subprocess.py(707): startupinfo, creationflags, shell, to_close,
subprocess.py(708): p2cread, p2cwrite,
subprocess.py(709): c2pread, c2pwrite,
subprocess.py(710): errread, errwrite)
--- modulename: subprocess, funcname: _execute_child
subprocess.py(1195): if isinstance(args, types.StringTypes):
subprocess.py(1198): args = list(args)
subprocess.py(1200): if shell:
subprocess.py(1205): if executable is None:
subprocess.py(1206): executable = args[0]
subprocess.py(1208): def _close_in_parent(fd):
subprocess.py(1215): errpipe_read, errpipe_write = self.pipe_cloexec()
--- modulename: subprocess, funcname: pipe_cloexec
subprocess.py(1167): r, w = os.pipe()
subprocess.py(1168): self._set_cloexec_flag(r)
--- modulename: subprocess, funcname: _set_cloexec_flag
subprocess.py(1149): try:
subprocess.py(1150): cloexec_flag = fcntl.FD_CLOEXEC
subprocess.py(1154): old = fcntl.fcntl(fd, fcntl.F_GETFD)
subprocess.py(1155): if cloexec:
subprocess.py(1156): fcntl.fcntl(fd, fcntl.F_SETFD, old | cloexec_flag)
subprocess.py(1169): self._set_cloexec_flag(w)
--- modulename: subprocess, funcname: _set_cloexec_flag
subprocess.py(1149): try:
subprocess.py(1150): cloexec_flag = fcntl.FD_CLOEXEC
subprocess.py(1154): old = fcntl.fcntl(fd, fcntl.F_GETFD)
subprocess.py(1155): if cloexec:
subprocess.py(1156): fcntl.fcntl(fd, fcntl.F_SETFD, old | cloexec_flag)
subprocess.py(1170): return r, w
subprocess.py(1216): try:
subprocess.py(1217): try:
subprocess.py(1218): gc_was_enabled = gc.isenabled()
subprocess.py(1221): gc.disable()
subprocess.py(1222): try:
subprocess.py(1223): self.pid = os.fork()
subprocess.py(1228): self._child_created = True
subprocess.py(1229): if self.pid == 0:
subprocess.py(1300): if gc_was_enabled:
subprocess.py(1301): gc.enable()
subprocess.py(1304): os.close(errpipe_write)
subprocess.py(1308): data = _eintr_retry_call(os.read, errpipe_read, 1048576)
--- modulename: threading, funcname: _after_fork
--- modulename: subprocess, funcname: _eintr_retry_call
subprocess.py(474): while True:
subprocess.py(475): try:
subprocess.py(476): return func(*args)
threading.py(1219): _active_limbo_lock = _allocate_lock()
threading.py(1222): new_active = {}
threading.py(1223): current = current_thread()
--- modulename: threading, funcname: currentThread
threading.py(1159): try:
threading.py(1160): return _active[_get_ident()]
threading.py(1224): with _active_limbo_lock:
threading.py(1225): for thread in _enumerate():
--- modulename: threading, funcname: _enumerate
threading.py(1181): return _active.values() + _limbo.values()
threading.py(1228): if hasattr(thread, '_reset_internal_locks'):
threading.py(1229): thread._reset_internal_locks()
--- modulename: threading, funcname: _reset_internal_locks
threading.py(700): if hasattr(self, '_Thread__block'): # DummyThread deletes self.__block
threading.py(701): self.__block.__init__()
--- modulename: threading, funcname: __init__
threading.py(260): _Verbose.__init__(self, verbose)
--- modulename: threading, funcname: __init__
threading.py(59): if verbose is None:
threading.py(60): verbose = _VERBOSE
threading.py(61): self.__verbose = verbose
threading.py(261): if lock is None:
threading.py(262): lock = RLock()
--- modulename: threading, funcname: RLock
threading.py(122): return _RLock(*args, **kwargs)
--- modulename: threading, funcname: __init__
threading.py(132): _Verbose.__init__(self, verbose)
--- modulename: threading, funcname: __init__
threading.py(59): if verbose is None:
threading.py(60): verbose = _VERBOSE
threading.py(61): self.__verbose = verbose
threading.py(133): self.__block = _allocate_lock()
threading.py(134): self.__owner = None
threading.py(135): self.__count = 0
threading.py(263): self.__lock = lock
threading.py(265): self.acquire = lock.acquire
threading.py(266): self.release = lock.release
threading.py(270): try:
threading.py(271): self._release_save = lock._release_save
threading.py(274): try:
threading.py(275): self._acquire_restore = lock._acquire_restore
threading.py(278): try:
threading.py(279): self._is_owned = lock._is_owned
threading.py(282): self.__waiters = []
threading.py(702): self.__started._reset_internal_locks()
--- modulename: threading, funcname: _reset_internal_locks
threading.py(567): self.__cond.__init__()
--- modulename: threading, funcname: __init__
threading.py(260): _Verbose.__init__(self, verbose)
--- modulename: threading, funcname: __init__
threading.py(59): if verbose is None:
threading.py(60): verbose = _VERBOSE
threading.py(61): self.__verbose = verbose
threading.py(261): if lock is None:
threading.py(262): lock = RLock()
--- modulename: threading, funcname: RLock
threading.py(122): return _RLock(*args, **kwargs)
--- modulename: threading, funcname: __init__
threading.py(132): _Verbose.__init__(self, verbose)
--- modulename: threading, funcname: __init__
threading.py(59): if verbose is None:
threading.py(60): verbose = _VERBOSE
threading.py(61): self.__verbose = verbose
threading.py(133): self.__block = _allocate_lock()
threading.py(134): self.__owner = None
threading.py(135): self.__count = 0
threading.py(263): self.__lock = lock
threading.py(265): self.acquire = lock.acquire
threading.py(266): self.release = lock.release
threading.py(270): try:
threading.py(271): self._release_save = lock._release_save
threading.py(274): try:
threading.py(275): self._acquire_restore = lock._acquire_restore
threading.py(278): try:
threading.py(279): self._is_owned = lock._is_owned
threading.py(282): self.__waiters = []
threading.py(1230): if thread is current:
threading.py(1233): ident = _get_ident()
threading.py(1234): thread._Thread__ident = ident
threading.py(1235): new_active[ident] = thread
threading.py(1225): for thread in _enumerate():
threading.py(1240): _limbo.clear()
threading.py(1241): _active.clear()
threading.py(1242): _active.update(new_active)
threading.py(1243): assert len(_active) == 1
subprocess.py(1228): self._child_created = True
subprocess.py(1229): if self.pid == 0:
subprocess.py(1231): try:
subprocess.py(1233): if p2cwrite is not None:
subprocess.py(1235): if c2pread is not None:
subprocess.py(1237): if errread is not None:
subprocess.py(1239): os.close(errpipe_read)
subprocess.py(1244): if c2pwrite == 0:
subprocess.py(1246): if errwrite == 0 or errwrite == 1:
subprocess.py(1250): def _dup2(a, b):
subprocess.py(1258): _dup2(p2cread, 0)
--- modulename: subprocess, funcname: _dup2
subprocess.py(1254): if a == b:
subprocess.py(1256): elif a is not None:
subprocess.py(1259): _dup2(c2pwrite, 1)
--- modulename: subprocess, funcname: _dup2
subprocess.py(1254): if a == b:
subprocess.py(1256): elif a is not None:
subprocess.py(1257): os.dup2(a, b)
subprocess.py(1310): if p2cread is not None and p2cwrite is not None:
subprocess.py(1312): if c2pwrite is not None and c2pread is not None:
subprocess.py(1314): if errwrite is not None and errread is not None:
subprocess.py(1318): os.close(errpipe_read)
subprocess.py(1320): if data != "":
subprocess.py(726): if mswindows:
subprocess.py(734): if p2cwrite is not None:
subprocess.py(736): if c2pread is not None:
subprocess.py(741): if errread is not None:
__init__.py(231): self.is_started = True
__init__.py(232): log.debug('process was started (pid=%s)', self.pid)
--- modulename: __init__, funcname: pid
__init__.py(137): if self.popen:
__init__.py(138): return self.popen.pid
--- modulename: __init__, funcname: debug
__init__.py(1139): if self.isEnabledFor(DEBUG):
--- modulename: __init__, funcname: isEnabledFor
__init__.py(1349): if self.manager.disable >= level:
__init__.py(1351): return level >= self.getEffectiveLevel()
--- modulename: __init__, funcname: getEffectiveLevel
__init__.py(1338): logger = self
__init__.py(1339): while logger:
__init__.py(1340): if logger.level:
__init__.py(1342): logger = logger.parent
__init__.py(1339): while logger:
__init__.py(1340): if logger.level:
__init__.py(1341): return logger.level
__init__.py(233): return self
--- modulename: __init__, funcname: wait
__init__.py(257): if timeout is not None:
__init__.py(263): if self._thread:
__init__.py(268): self._wait4process()
--- modulename: __init__, funcname: _wait4process
__init__.py(273): if self._outputs_processed:
__init__.py(276): def remove_ending_lf(s):
__init__.py(282): if self.popen:
__init__.py(283): if self.use_temp_files:
__init__.py(284): if USE_POLL:
__init__.py(294): self.popen.wait()
--- modulename: subprocess, funcname: wait
subprocess.py(1374): while self.returncode is None:
subprocess.py(1375): try:
subprocess.py(1376): pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0)
--- modulename: subprocess, funcname: _eintr_retry_call
subprocess.py(474): while True:
subprocess.py(475): try:
subprocess.py(476): return func(*args)