Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should spawn.close() set self.pid to None? #696

Open
esharakan opened this issue Aug 11, 2021 · 0 comments
Open

Should spawn.close() set self.pid to None? #696

esharakan opened this issue Aug 11, 2021 · 0 comments

Comments

@esharakan
Copy link

Hi, I have code that subclasses pexpect.spawn. In that code, we loop if the underlying spawned process doesn't connect properly the first time. In that case we call self.close() from the subclass and then loop back to calling the superclass's __init__ method again, where we encounter this:

Traceback (most recent call last):
  File "/opt/SUNWldm/test/memblocks.py", line 241, in testmemblocks
    self.do_testmemblocks()
  File "/opt/SUNWldm/test/memblocks.py", line 338, in do_testmemblocks
    ldom.id - 1, self)
  File "/opt/SUNWldm/test/lib/ldomconsole.py", line 115, in __init__
    encoding='utf-8', codec_errors='ignore')
  File "/usr/lib/python3.7/vendor-packages/pexpect/pty_spawn.py", line 205, in _
_init__
    self._spawn(command, args, preexec_fn, dimensions)
  File "/usr/lib/python3.7/vendor-packages/pexpect/pty_spawn.py", line 283, in _
spawn
    assert self.pid is None, 'The pid member must be None.'
AssertionError: The pid member must be None.

If I explicitly set self.pid to None in my code after calling self.close(), the problem goes away. Shouldn't spawn.close() do that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant