#3016 Interp limit functionality with vwait call

obsolete: 8.5a2
closed-fixed
5
2004-12-16
2004-12-14
Anonymous
No

It seems that vwait will not break when timeout
limit is hit. The following script does not stop:

set testvar ""
interp limit {} time -seconds 5
vwait testvar

Discussion

  • Logged In: NO

    Small addition - first time this problem appeared when I
    tryed to break script execution from C code by setting
    further execution time to one second - result was the
    same.
    P.S. Probably it would be handy to have
    "Tcl_SetLimitExceeded" to break executing script

    nyrl@mail.ru

     
  • Don Porter
    Don Porter
    2004-12-14

    • labels: 105684 --> 20. [interp]
    • assigned_to: dgp --> dkf
     
  • Logged In: YES
    user_id=79902

    Yeah, I've known about this issue for a while. Not sure how
    to fix it yet though.

     
  • Logged In: YES
    user_id=79902

    Examining what I've done so far, setting up a no-action
    timer with Tcl_CreateTimerHandler will be sufficient; that
    can be done at the same time as the creation of the time limit.

     
  • Logged In: NO

    This doesn't seems to work, TimerHandler call doesn't
    seems to activate timeout check even with time
    granularity 1. Possible further problems - there are cases
    when timeout limit check is called too rarely, so it can be
    handy to force such a check each second. Imho, this can
    be done by changing waiting loops (Tcl_Sleep and
    Tcl_DoEvent) to do a limited wait, calling Tcl_CheckLimits
    from time to time without checking time granularity.

    Also I've found a small bug with time limits.
    Tcl_SetTimeLimit sets relative timeout while
    Tcl_CheckLimits check absolute timeout. Changes in
    Tcl_SetTimeLimit like
    Tcl_GetTime(&now);
    usec = iPtr->limit.time.usec + now.usec;
    iPtr->limit.time.sec += now.sec + usec / 1000000;
    iPtr->limit.time.usec = usec % 1000000;
    iPtr->limit.exceeded &= ~TCL_LIMIT_COMMANDS;
    works, but when You call
    puts "Limit is: [ interp limit {} time ]"
    from script You'll get absolute timeouts, what can be
    misguiding.

    nyrl@mail.ru

     
  • Logged In: YES
    user_id=79902

    There was a minor error (wrong comparison operator!) in the
    time limit evaluation code that made it postpone enforcing
    the limit until the end of the second. :^}

    Fixing blocking [after] is unpleasant, but fairly
    straight-forward.

    Fixing blocking [exec] (or other blocking IO) is beyond what
    I understand how to do at the moment. :^(

     
    • status: open --> closed-fixed
     
  • Logged In: YES
    user_id=79902

    Fixed [vwait], [update] and [after <num>] to be time-limit
    aware.

    The fix for [vwait] and [update] is elegant (a timer event
    that checks the limit at the time when the limit is expected
    to be exceeded) and the fix for blocking [after] is not
    (fragment the blocking wait!) but all cases should now work.

    Thanks for reporting this!