-
Notifications
You must be signed in to change notification settings - Fork 475
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
asyncio integration for expect #69
Conversation
Pexpect was mentioned on the tulip mailing list some time back, "Interacting with sys.stdin/sys.stdout/sys.stderr", https://groups.google.com/forum/#!msg/python-tulip/6tRswyRhwE4/90D1_B1NWEcJ Trollious may allow us to remain py27 compatible. |
My plan for Pexpect 4 is to refactor the core of pexpect so that it's easy to write async wrappers - I think this mostly just means breaking out the core of I don't want to provide support in Pexpect for other async frameworks - trollius, tornado, twisted, etc. (is there something about the letter T and async?). But the refactoring should make it practical for other people to integrate Pexpect with those frameworks if people need to. |
OK, this is now taking on the rough shape that I want, if you want to start reviewing it. In an asyncio coroutine, you can replace: idx = p.expect('foo') with this non-blocking version: idx = yield from p.expect('foo', async=True)
I also plan to allow an asynchronous version of |
Cool, I plan to try to use pexpect for functional testing with an asyncio telnet project, I'll make an effort to use use pexpect using asyncio patterns. |
OK, I think this is ready for review. The new parameters are documented, and there are some basic tests, which are passing. |
will review this weekend, been on vacation recently as well :) |
I think the most important bit for review is the design of the new Expecter class, which separates out the bits that were previously inside I plan to mark Expecter as a 'provisional' API for 4.0, in case it turns out we need to change it. After that it will become a public API that people can use to integrate Pexpect with other async frameworks. |
We will drop support for these Python versions in Pexpect 4.0
@jquast, I'm merging this to keep things moving forwards. Feel free to do post-merge review. |
asyncio integration for expect
sure will. been a bit full with work/life balance, but have a 2-week stay-at-home-vacation coming up this month. |
This is a first stab at integrating Pexpect with asyncio, to allow waiting for more than one process at once. Using it looks like this, although the API is almost certainly going to change before release. So far, I've only implemented async behaviour for expecting a pattern in output - we could add async support for writing large amounts of data to the pty, for opening the connection, for wait() and waitnoecho().
Status updated, see below.