you are viewing a single comment's thread
view the rest of the comments
[–] 57 points 2 years ago (5 children)

My secret to high uptime:

while True:
    try:
        main()
    except:
        pass
  • source
  • hideshow 10 child comments
  • [–] 3 points 2 years ago (3 children)

    Lurking beginner here, why is this bad?

  • source
  • parent
  • hideshow 6 child comments
  • [–] 12 points 2 years ago (1 child)

    There you go:

    # Start an infinite loop because True will always be True
    while True: 
        # try to run the main function, usually where everything happens
        try:
            main()
        # in the case an exception is raised in the main function simply discard (pass) and restart the loop
        except:
            pass
    
  • source
  • parent
  • hideshow 2 child comments