textadept_11.4_alpha get stuck on filter_through large file #194
Replies: 6 comments 3 replies
-
Thanks for the report. I'll take a look when I have some time.
|
Beta Was this translation helpful? Give feedback.
0 replies
-
After looking into this, I have concluded that it is an OS-specific issue with GTK's process spawning capabilities with no clear workaround. For commands that emit stdout while reading stdin (as opposed to emitting stdout after stdin is closed), if the stdout pipe/buffer gets full, input can no longer be read. In my tests on Linux, Textadept is hanging on writing input to the process after that process has emitted a little over 100K to stdout. I don't know if there is a heuristic that can be applied such that stdin is broken up into chunks (e.g. 64K blocks) and stdout read every now and then vs. the existing approach of passing all stdin and reading stdout after the fact. I don't know what to do here, sorry :(
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
amitbha
-
I have committed some warnings on this by the way: 2d48870
|
Beta Was this translation helpful? Give feedback.
1 reply
-
I think the closest you can come to async read/write would be to do something like this (untested):
local stdout = {}
local function handle_stdout(s) stdout[#stdout + 1] = s end
local p = os.spawn('cat -s', handle_stdout)
for i = 1, #input, 65535 do
p:write(input:sub(i, i + 65535))
ui.update() -- will call handle_stdout if any is available
end
p:wait()
stdout = table.concat(stdout)
`input` is a really large string, and `stdout` ends up holding the entire stdout of the process. This will only work if the spawned process emits stdout while reading stdin.
The above example emulates coroutines because `ui.update()` passes control to GTK, which invokes the process stdout handler, and then passes back control to Lua when done.
|
Beta Was this translation helpful? Give feedback.
1 reply
-
Oops, I forgot that you need `p:close()` before `p:wait()`. This ends an EOF to the process stdin.
|
Beta Was this translation helpful? Give feedback.
0 replies
-
That is correct. Only those types of commands need to be handled specially.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
OS: Manjaro 21.2.5
Version: textadept_11.4_alpha
The file The_Mutt_manual.md has 6900+ lines. While press
Ctrl+|
to filter_throughcat -s
to reduce blank lines, the textadept get stuck.Use
strace
to check what happened:Beta Was this translation helpful? Give feedback.
All reactions