time.sleep() function

3 thoughts on “time.sleep() function

  1. I am tweaking a send-response communication routine between HE910 and a sensor with MODBUS port. Using the time.sleep() function between send and receive commands, I have come down from time.sleep(1)  to time.sleep(0.05) and there seems to be a difference in communication failure percentages, depending on the argument put in the time.sleep()  function.

    But a question arises: what is a meaningful mimimum parameter value here? And what is the overhead timing, roughly, for this function? I mean, setting time.sleep(0), what is the delay anyway?

    And of curiosity, is there a max. value also? Something like sleeping until the next ice age? 🙂

    1. While we are waiting for some eventual numbers from colleagues, I can only make comments:

      – the minimum value is only a weak reference because of the low priority of Python task, harder to fulfil as it gets lower

      – if you need ice age maximum values better use MOD.powerSaving() :))


      1. I think that this minimal value should depend from your sensor.
        I suppose that the sensor didn’t have enough time to answer, if the sleep was too short.
        However, it is difficult to define a minimal value, because Python doesn’t work in real time and if there is a task with higher priority, the execution of python task can be delayed.


        Regarding a maximum value for this function, the time.sleep function is a Python standard and the type of variable is a float, which should be more than enough.