Comments (3)
have you tried adding a short delay before calling capture_pane
?
It seems that capture_pane
returns the text it finds at the time it's called. This can lead to race conditions when commands from send_keys()
or cmd()
might take longer to execute than the call to capture_pane()
.
Example:
I encountered the same problem when using it to call a custom script:
script: my-server serve api
*This script just launches a small REST server. Once initialized it prints the version number, along with some default messages from Flask.
I also found that my .bashrc setup can contribute to some delays, my setup has a slight delay so I print a message to the console once it's finished.
no delay
pane.send_keys('my-server serve api')
stuff = pane.capture_pane()
print(stuff)
Output: [' my-server serve api']
slight delay
pane.send_keys('my-server serve api')
time.sleep(2)
stuff = pane.capture_pane()
print(stuff)
Output: [' my-server serve api', '.bashrc loaded', '<user>@<host>:/path/to/dir$ my-server serve api']
slightly longer delay
pane.send_keys('my-server serve api')
time.sleep(5)
stuff = pane.capture_pane()
print(stuff)
Output: [' my-server serve api', '.bashrc loaded', '<user>@<host>:/path/to/dir$ my-server serve api', 'LAUNCHING SERVER: (3.4.3)', ' * Serving Flask app "path/to/dir/server.py"', ' * Environment: production', ' WARNING: Do not use the development server in a production environment.', ' Use a production WSGI server instead.', ' * Debug mode: off', ' * Running on http://127.0.0.1:5050/ (Press CTRL+C to quit)']
Note: some values such
<user>
and<host>
were altered above for privacy
from libtmux.
In fact, it seems that the command is executed if i check it manually with tmux capture-pane
but the problem is that it only returns just the first line.
If i replace 'cowsay hello' with say 'ls -rtl' it works and all the lines are returned
It i replace 'cowsay hello' with 'ls -rtl | fzf', only the first line is returned too
Any ideas ?
from libtmux.
Thanks @lwthatcher , didn't tried it yet, but i indeed encounter the same behaviour with another tmux library (https://github.com/jhawthorn/ttytest) and adding a delay of 0.1 between 'send-keys' solved my problems.
I wasn't aware too at first, that 'send-keys' don't wait a return of the command and need to be test manually.
Closing since it seems related to a delay between commands.
Thanks,
from libtmux.
Related Issues (20)
- Tests failing on ppc64le HOT 2
- Tests failing on aarch64 HOT 2
- Tests failing on armv7l HOT 3
- Intermittent errors with tests on x86_64 / amd64 HOT 7
- Intermittent errors with tests on i586 (32bit)
- Is there any way to connect to a tmux session on a remote machine? HOT 1
- Intermittent / flaky test test_capture_pane
- select_pane not working correctly with multiple sessions HOT 2
- Drop Python 3.7 HOT 1
- `build(build-system)`: Remove `setuptools` build dependency
- unknown pytest option --doctest-docutils-modules HOT 7
- Unable to access server via WSGI HOT 4
- `TmuxObjectDoesNotExist` when creating `libtmux.Server().new_session(attach=True)` HOT 13
- Remove assert from __eq__ for windows HOT 5
- Tests failing with "FileNotFoundError: [Errno 2]" and "Unknown directive type: 'currentmodule' [myst.directive_unknown]" HOT 6
- Tests: Snapshots
- Options: Typed structures
- Environment: Add to `new-window`, `split-window`, `respawn-window`, `respawn-pane`
- No implicit exports from __init__.py HOT 1
- `pane.send_keys()` doesn't send cmd to correct pane when cmd has a `-t` flag HOT 3
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 libtmux.