[SOLVED] Interpreter delay on 2.7?

5 thoughts on “[SOLVED] Interpreter delay on 2.7?

  1. I’m trying to figure out why we get such choppy performance in Python 2.7. Our scenario is this:

    MCU             UL865

    1– Get data –>|

    |               |_

    |               | | 2 Read data from flash

    |               |_|

    |               | 

    |<—- Data —-3

     

    The full cycle 1-3 takes around 100ms which is fine in this stage. Step 3 takes around 5ms, but then something strange happens. After step 3 has completed nothing happens for 500ms and I’m trying to figure out why.

     

    I recall seeing something about the interpreter being stalled for 50ms every second in the old 1.5 manual, but what we’re seeing here is much larger. Has this changed in 2.7?

    I have previously verfied this by running the Python scripts on the computer and sending data to the MCU that way, and IIRC I didn’t see such a delay so I think the MCU part works.

    1. I just tried with a simple script which does nothing but reading data from SER and sending a packet of 5 bytes every second, and it does not show this behavior. The delay must come from somewhere in my code.

    2. Ok, I have figured out what’s causing the delay but not why. We have written a custom logger which outputs debug data to SER2 in the following format:

       

      [timestamp] [file:line] [message]

       

      Generating a timestamp using time.time() takes 100ms. Generating a timestamp using time.clock() is instantaneous. Is this intentional?

       

       

       

      import time

       

      old = time.clock()

      time_last_sent = 0

       

      while True:

          this_will_cause_delay = time.time()

       

          # Print how long it took to make one iteration. Every now and then

          # this will be around 500ms

          new = time.clock()

          print ‘Iteration tool {}s’.format(new – old)

          old = new