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

Cannot catch before if program exits immediately #3

Closed
raczben opened this issue May 13, 2019 · 5 comments
Closed

Cannot catch before if program exits immediately #3

raczben opened this issue May 13, 2019 · 5 comments
Labels
bug Something isn't working

Comments

@raczben
Copy link
Owner

raczben commented May 13, 2019

Issue: wexpect cannot wait on EOF properly. The before field wont contain the program's output if it has no prompt.

Reproduce:

import wexpect
import time
p = wexpect.spawn('uname')
time.sleep(1)
p.expect(wexpect.EOF)
p.before
@raczben raczben added bug Something isn't working help wanted Extra attention is needed labels Aug 12, 2019
@raczben
Copy link
Owner Author

raczben commented Sep 4, 2019

tests.test_constructor.TestCaseConstructor.test_constructor testcase fails due to this issue.

@raczben
Copy link
Owner Author

raczben commented Sep 4, 2019

Here is a workaround:

insert the following line at the end of the _spawn() function of the spawn_windows class. (~ line: 1740)

        try:
            self.expect(EOF, timeout = 0)
        except:
            pass

raczben pushed a commit that referenced this issue Nov 14, 2019
raczben pushed a commit that referenced this issue Nov 14, 2019
@raczben raczben removed the help wanted Extra attention is needed label Feb 23, 2020
@nmz787
Copy link

nmz787 commented Mar 3, 2020

similarly, you can't get the output to print for debugging/monitoring... i.e.

import wexpect
import time
import sys
p = wexpect.spawn('uname')
p.logfile_read = sys.stdout
time.sleep(1)
p.expect(wexpect.EOF)
p.before

@raczben
Copy link
Owner Author

raczben commented Mar 5, 2020

This issue will be solved when the new-structure-wexpect will be stable and default.

@raczben
Copy link
Owner Author

raczben commented Feb 1, 2021

Fixed in v4.0.0

@raczben raczben closed this as completed Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants