5 thoughts on “[SOLVED] Interpreter delay on 2.7?”
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.
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.
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
We use cookies to enhance your browsing experience and help us improve our websites. To improve our website, we carefully select third parties that use cookies to allow us to serve specific content and achieve the purposes set out in our cookie policy. For more information on how to make adjustments through your browser to the cookies being used on your device, please click Find Out More link. By closing this banner or continuing to browse our website, you agree to our use of such cookies. FIND OUT MORE
I’m trying to figure out why we get such choppy performance in Python 2.7. Our scenario is this:
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.
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.
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?
Hi Marco,
firmware version?
12.00.603-B063