0

I'm working on a mail sending python script in Linux.

I can send 10 messages, then need to wait 5 - 10 minutes before sending again.

I am executing the following code inside of a while() loop.

#Pausing so the MailServer doesn't complain
delay = randint(300,600)
now = datetime.now()
current_time = now.strftime("%H:%M:%S")
print(current_time + " sleeping " + str(timedelta(seconds=delay)))
sleep(delay)

This causes the program to hang whether it is at the beginning of the loop or end.

While stepping through with pdb, I can't detect the issue.

I am not using threading (just because I haven't learned how yet).

I'm open to ideas.

martineau
  • 119,623
  • 25
  • 170
  • 301
Andy Delgado
  • 31
  • 1
  • 4

0 Answers0