0

I have this piece of code:

import time

def printAtInterval():
    print('text')
    time.sleep(60 - time.time() % 60)

def getCommand():
    command = input()
    if command == 'help':
        print('something')

while True:
    getCommand()
    printAtInterval()

The problem with this code is obvious, I can't input anything while the process is waiting for the time to elapse. I'd like to have them both working at the same time.

NotLatif
  • 1
  • 3
  • Maybe this will help you https://stackoverflow.com/questions/10941851/grab-user-input-asynchronously-and-pass-to-an-event-loop-in-python – Orestis Zekai May 25 '20 at 10:40
  • Try to look to `threading` module. Your question is about parallel computing. – pyOliv May 25 '20 at 11:32
  • The other comments are correct, however for this specific task I would recommend you to use https://pypi.org/project/schedule/ – bb1950328 May 25 '20 at 12:45

0 Answers0