anyone found a way around 4-5 second latency in read from process?

Sarah Reichelt sarah.reichelt at gmail.com
Mon Feb 8 17:09:34 EST 2010


On Tue, Feb 9, 2010 at 6:24 AM, Josh Mellicker <josh at dvcreators.net> wrote:
> We have been experimenting with many combinations of syntax variants  for "open process"/"read from process" to communicate with various command-line driven executables.
>
> We are using a callback loop to read from process, and have tried from 1 to 800 milliseconds to try and speed up response.
>
> We have tried read from process until lf, until cr, until eof, until empty, etc.
>
> Things are working, but there is always about a 4 - 5 second latency in the "read from process". Usually this doesn't matter, but in our current project it needs to be within a second or less.
>
>
> So, I am wondering:
>
> 1. Is there something we could do to eliminate this delay, some syntax we haven't yet tried?
>
> 2. Have other developers noticed this latency in the Rev I/O pipeline?
>
> 3. Would writing an Rev external that served as a middleman between Rev and a command-line driven executable eliminate this problem and provide near real time communication?
>
> 4. Is there another way to communicate with command-line driven executables (other than "shell", which doesn't provide for a callback loop to monitor output)


I use shell with the output piped to a text file that I can monitor.
Here is an example script that I use for pinging:

function checkPing pIP
    put specialFolderPath("Desktop") & "/ping.txt" into tFileName
    if there is a file tFileName then delete file tFileName

    put "ping -c1 -n "  & pIP into tShellCmd
    put " > " & tFileName & " 2>&1 &" after tShellCmd
    get shell(tShellCmd)

    put 0 into timeCheck
    repeat 50 times
        add 1 to timeCheck
        wait 1 tick with messages
        if there is a file tFileName then
            put URL ("file:" & tFileName) into tRes
            if tRes is empty then next repeat  -- file created but no result yet

            put wordOffset("loss", tRes) into tWord
            if tWord = 0 then next repeat -- file created but result
not complete

            -- if there is a file tFileName then delete file tFileName
            put word tWord-2 of tRes into tPercent
            if tPercent = "0%" then return true
            else return false
        end if
    end repeat

    if there is a file tFileName then delete file tFileName
    return false
end checkPing

Cheers,
Sarah



More information about the use-livecode mailing list