Time.sleep() slows down abruptly from the intended set time

Problem description: I am making a game that prints dialogue in a typewriter sort of style, where each character is printed using a for loop and time.sleep(0.04) as the delay for each character. (link to code below)

Expected behavior: The code works fine, and each character should print with a 0.04 sec delay between each character.

Actual behavior: The delays abruptly slows down when the set value for time.sleep() is less than 1 sec. As a result, the rate at which characters are printed, is much slower, but still constant. The code worked perfectly fine, without this odd bug a few weeks back. I suspect a Replit update may have caused the code to stop working as intended.

**Steps to reproduce: Here is the code:
import sys, time

def slow1(message): # fast crawl
for letter in message:
sys.stdout.write(letter) # prints on screen (without delay between letters)
sys.stdout.flush()
time.sleep(0.04)
print(“\n”)

msg = “[MAD WIZARD] I am the villain of the story. Here is my evil dialogue, which will cause millions of deaths!”
slow1(msg)
**

Bug appears at this link: https://replit.com/@JadonXia1/scrap2?v=1

Browser/OS/Device: Chrome/Windows/Laptop

Hi there! First off, its always in good spirit to format your code like this:

#Steps to reproduce: Here is the code:
import sys, time

def slow1(message): # fast crawl
 for letter in message:
  sys.stdout.write(letter) # prints on screen (without 
   delay between letters)
  sys.stdout.flush()
  time.sleep(0.04)
  print(“\n”)

msg = “[MAD WIZARD] I am the villain of the story. Here is my evil dialogue, which will cause millions of deaths!”


Just helps some of us read a bit, what with syntax highlight. As for your bug, your hypothesis may be right. If this was a Replit bug, I would contact a staff member like @ShaneAtReplit. They can help you from there. Anyways, good luck!

2 Likes

how do i contact shane

1 Like

If you can, go to his user page and click “Message” to start a PM chat with him.

1 Like

Hey! Please don’t message us directly. We keep track of every post, but if we don’t get to you within a few days, you can ping Bardia or I (for the time being as we sort out our workflows).

I think this issue is related to: Text laggy when simulating typing in Python repls - #15