Comments (12)
Thank you very much for the reproducable issue, this may be formed into a test case.
I'm not convinced it is unavoidable gotchya. may be a bug, marking as such for now. otherwise the fix will be documentation.
from pexpect.
Its definitely avoidable, pexpect just needs to (if my suspicion of cause is correct) identify the pipe buffer size and flush before it hits that (with sendeof).
This would also require a some documentation fixes though because I seem to remember an implication that pexpect only flushes on newline or sendeof.
Even if pexpect doesn't do it automatically, auto flushing would be a cool feature to have.
from pexpect.
To clarify: "even if pexpect does not have it enabled by default, it would be a nice option to have".
from pexpect.
For my own reference, http://unix.stackexchange.com/questions/11946/how-big-is-the-pipe-buffer
from pexpect.
There isn't much we can do here, if we tried to batch calls to sendline() that were larger than an arbitrary length, we're assuming whatever child process you're sending to would be ok with that, base64(1) is, but others are not. If you were using bash(1) directly with a really huge command-line, you would know that you have to break it with lines ending '\'
, for example.
I think if you were using base64(1) you would understand that you should batch chunks to sendline:
chunk=80
X='X'*10000
map(c.sendline, [X[start:start+chunk] for start in range(0, len(X), chunk)]
from pexpect.
Hmm, but you don't actually need to split it up into sendlines right?
As I note (hidden away, admittedly) - "If, in batching mode, you replace sendline with a send then sendeof it also works."
This is because the sendeof flushes the buffer (I think?).
So if pexpect counted the number of characters it has sent and flushes via sendeof automatically I think it would work.
from pexpect.
sendeof just sends the equivalent of ctrl+d. I wouldn't want to send that arbitrarily, but maybe we can flush the file descriptors, I'll try for a test
from pexpect.
Thanks.
Am happy with it just being a doc fix if it comes down to it.
from pexpect.
The BEL (\x07
) is your terminal driver speaking -- you've reached the maximum input line for canonical input processing. Executing stty -icanon
will disable canonical input, and allow you to exceed PC_MAX_CANON. Proof by test case follows:
def test_max_canon(self):
" BEL is sent by terminal driver when MAX_CANON is reached. "
p = pexpect.spawn('cat', echo=False, timeout=3)
p.sendline('_' * (os.fpathconf(p.child_fd, 'PC_MAX_CANON') - 1))
with self.assertRaises(pexpect.TIMEOUT):
p.expect('\a', timeout=1)
p.sendline('_' * (os.fpathconf(p.child_fd, 'PC_MAX_CANON')))
p.expect('\a', timeout=1)
def test_max_no_icanon(self):
" MAX_CANON may be exceed if canonical mode is disabled for input. "
p = pexpect.spawn('bash', echo=False, timeout=3)
# disable canonical mode processing of input,
p.sendline('stty -icanon')
p.sendline('cat')
p.sendline('_' * (os.fpathconf(p.child_fd, 'PC_MAX_CANON') + 1))
with self.assertRaises(pexpect.TIMEOUT):
p.expect('\a', timeout=1)
I'll add a docstring to sendline.
from pexpect.
Oh interesting, so nothing to do with pipe buffers whatsoever. I learn new things every day.
from pexpect.
Now that I've got a SunOS, MacOSX, and Linux build slave up I've been able to refine the tests and documentation regarding MAX_CANON, Pull request #79 will close this issue. Thanks.
from pexpect.
Closed by #79.
from pexpect.
Related Issues (20)
- Issue with Select module HOT 3
- Support for new release HOT 3
- Two tests hang on `cat` HOT 3
- test_large_stdout_stream timeout HOT 1
- REPLWrapTestCase.test_existing_spawn fail on illumos HOT 1
- sdist is missing requirements-testing.txt
- AttributeError: module 'asyncio' has no attribute 'coroutine' HOT 1
- Incorrect DEVELOPERS.rst
- False positive expect_exact HOT 1
- Test REPLWrapTestCase.test_pager_as_cat fails.
- An asterisk appearing out of nowhere with Clojure
- Time for a release: any reason to delay? HOT 5
- 4.9.0: git tag does not match PyPI version HOT 2
- Handling SIGTSTP possible?
- Docs not updated for 4.9?
- 4.9: pytest fails in 3 units HOT 1
- "expect()" and "await expect()" have different results on completed processes
- Pexpect does not implement enough asynchronous methods to prevent the use of time.sleep().
- add contribution documentation
- Pxssh sometime does not capture the full output of previous `sendline`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pexpect.