Member Avatar for leegeorg07

hi again
i have this code:

#this program is a simple test OS for a till
#it will loop constantly until a certain time (specified as CLOSING_TIME) COMPLETED!!!
#it will check stock from a dictionary in a file (specified as STOCK)
#i plan to add a profit calculator
import time
OPENING_TIME = '17:17:30'
CLOSING_TIME = '17:17:59'
current_time = time.asctime()[11:19]
def isopen(opening_time):
    current_time = time.asctime()[11:19]
    while current_time < OPENING_TIME:
        current_time = time.asctime()[11:19]
        time.sleep(1)
    print("we are now open")
def maintill(closing_time):
    while 1:
        current_time = time.asctime()[11:19]
        while current_time < CLOSING_TIME:
            current_time = time.asctime()[11:19]
        print("we are closing now, please leave the store.")
        break
isopen(OPENING_TIME)
maintill(CLOSING_TIME)

i now want to add in a basic till into the maintill(closing_time) function but im worried that it will hang until someone finishes inputting data, thus not allowing it to update closing_time. how could i stop this from happening?

Member Avatar for leegeorg07

i was thinking of another function but i wasnt sure if that would work?

Perhaps a little more detail will help with giving you better options.

Is it OK for the user to be asked for input and then wait until after they are done to determine if it's past closing time? You could then just ignore the input.

If the user must be allowed to enter input and simultaneously check for closing time, you will probably need some sort of event-driver code. Perhaps using a GUI framework would be the best route.

Basically, it comes down to if you need to do things in your code right at the time of closing or if it's OK to wait until the user has finished entering input.

Member Avatar for leegeorg07

i never thought of that, i suppose i could always have it closing late, thanks i'll leave this open if need any more help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.