Python recursion limit

前端 未结 3 1078
太阳男子
太阳男子 2021-01-23 17:54

So I understand the reason for the recursion limit of 1000. I want to run a script continuously, but am I right understanding that eventually the recursion limit will be reache

3条回答
  •  春和景丽
    2021-01-23 18:50

    You're going about this in the wrong way.

    Replace the main loop with a loop.

    # main logic
    def main():
        while True:
            all_files = getFiles(LOC_DIR)
            files = []
            for f in all_files:
                if checkExt(f):
                    files.append(f)
            if len(files) == 1:
                printLog('<<< Found %s matching file >>>' % len(files))
            elif len(files) > 1:
                printLog('<<< Found %s matching files >>>' % len(files))
            for f in files:
                if checkSize(f):
                    rsyncFile(f)
            printLog('No files found.  Checking again in %s seconds' % RUN_INT)
            time.sleep(RUN_INT)
            printLog('Checking for files')
    

提交回复
热议问题