Forums

Stall after time.sleep

In my main flask I call a routine that starts a thread:

trackingUpdateThread = threading.Thread(target=localLiveTrackingUpdater, args=(trackingType, "RemoteTransmuter", None))
 trackingUpdateThread.daemon = True
 trackingUpdateThread.start()

The thread code is this:

def localLiveTrackingUpdater(trackingType, streamName, usePort):
print(f'STARTUP: state={state} now={now/1000.0} trackingType={trackingType} {trackingType == TRANSMUTER}')
if trackingType == TRANSMUTER:
    print('Launching TRANSMUTER...')
    toProcess = []
    ikeyToFlush = []
    iKey = ""
    NPIndex = None
    seqCounter = 0
    dataArrivedAt = None
    while True:
        print('Tick...')
        time.sleep(1.0)
        print(f'TRANSMUTER tick...')

I never see the last print (TRANSMUTER tick...) in any logs. I see all the rest.

What I need is to run this thread once a second to look at data that's been pushed to the site.

I have a paid account - so I assume I have enough threads. I don't see any other restrictions on time.sleep().

The rest of the site works fine.

Need help...

"Can I just use threads? -- we don't support threads in web apps, no"

From: https://help.pythonanywhere.com/pages/AsyncInWebApps/

That's correct, you can't use threads.