Announcement

Collapse
No announcement yet.

miva_sleep Not Working

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    miva_sleep Not Working

    miva_sleep is not evaluating.

    Code:
    <mvt:assign name="g.sleep_start" value="s.dyn_time_t" />sleep_start: <mvt:eval expr="g.sleep_start" /><br>
    <mvt:assign name="g.has_sleep" value="miva_sleep(500)" />has_sleep: <mvt:eval expr="g.has_sleep" /><br>
    <mvt:assign name="g.sleep_end" value="s.dyn_time_t" />sleep_end: <mvt:eval expr="g.sleep_end" /><br>
    <mvt:assign name="g.sleep_duration" value="g.sleep_end - g.sleep_start" />sleep_duration: <mvt:eval expr="g.sleep_duration" /><br>
    Tried a while loop but it does not work

    Code:
    <mvt:assign name="g.while_delay_start" value="s.dyn_time_t" />while_delay_start: <mvt:eval expr="g.while_delay_start" /><br>
    <mvt:assign name="g.while_delay" value="500" />while_delay: <mvt:eval expr="g.while_delay" /><br>
    <mvt:assign name="g.while_delay_stop" value="g.while_delay_start + g.while_delay" />while_delay_stop: <mvt:eval expr="g.while_delay_stop" /><br>
    <mvt:while expr="s.dyn_time_t LE g.while_delay_stop">
    </mvt:while>
    <mvt:assign name="g.while_delay_end" value="s.dyn_time_t" />while_delay_end: <mvt:eval expr="g.while_delay_end" /><br>
    <mvt:assign name="g.while_duration" value="g.while_delay_end - g.while_delay_start" />while_duration: <mvt:eval expr="g.while_duration" /><br>
    I prefer to work with miva_sleep() . What is wrong with code?
    http://www.alphabetsigns.com/

    #2
    You do know that miva_sleep measures time in milliseconds, right?
    Kent Multer
    Magic Metal Productions
    http://TheMagicM.com
    * Web developer/designer
    * E-commerce and Miva
    * Author, The Official Miva Web Scripting Book -- available on-line:
    http://www.amazon.com/exec/obidos/IS...icmetalproducA

    Comment


      #3
      Hi Kent, Thanks for the reply.

      Yeah, its just a half a second.

      The code snippet benchmarks the miva_sleep() and returns 0.

      I'm getting timestamps so I don't think its a server issue but something is wrong.

      I don't want to use a while loop because its CPU heavy.

      Could you look at or test the code and see if you eval a sleep_duration?
      http://www.alphabetsigns.com/

      Comment


        #4
        s.dyn_time_t is a number of seconds. So if your script runs for only half a second, s,dyn_time_t can't advance more than 1; and about half the time, it won't advance at all.

        I tested your script after changing the "500" to "g.sleep_time," so that I could enter different numbers as a URL parameter. With 500, as expected, it shows sleep_duration results of 0 or 1. I changed the sleep time tp 5000, i.e. 5 seconds, and I got a noticeable delay. So I think the software is performing correctly, at least in my store.
        Kent Multer
        Magic Metal Productions
        http://TheMagicM.com
        * Web developer/designer
        * E-commerce and Miva
        * Author, The Official Miva Web Scripting Book -- available on-line:
        http://www.amazon.com/exec/obidos/IS...icmetalproducA

        Comment


          #5
          Thank you for taking the time to test the code and your explanation makes sense.

          I see what I did wrong and will fix it tomorrow.

          I'm using this to debug a race issue that I think I'm having. Or it may not be a race issue but something completely different.

          TGIF

          http://www.alphabetsigns.com/

          Comment


            #6
            Thanks for the update on this.
            Larry
            Luce Kanun Web Design
            www.facebook.com/wajake41
            www.plus.google.com/116415026668025242914/posts?hl=en


            Comment

            Working...
            X