mirror of
https://github.com/karpathy/nanochat.git
synced 2026-03-07 09:50:28 +00:00
fix: replace bare except clauses with except Exception
Bare `except:` catches BaseException including KeyboardInterrupt and SystemExit. Replaced 5 instances with `except Exception:`.
This commit is contained in:
parent
c7ba252142
commit
d5c307ae67
|
|
@ -95,7 +95,7 @@ def download_single_file(index):
|
|||
if os.path.exists(path):
|
||||
try:
|
||||
os.remove(path)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
# Try a few times with exponential backoff: 2^attempt seconds
|
||||
if attempt < max_attempts:
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ def run_command(cmd):
|
|||
if result.returncode == 0:
|
||||
return ""
|
||||
return None
|
||||
except:
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
def get_git_info():
|
||||
|
|
@ -237,7 +237,7 @@ def extract_timestamp(content, prefix):
|
|||
time_str = line.split(":", 1)[1].strip()
|
||||
try:
|
||||
return datetime.datetime.strptime(time_str, "%Y-%m-%d %H:%M:%S")
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
return None
|
||||
|
||||
|
|
|
|||
|
|
@ -559,7 +559,7 @@ while True:
|
|||
if first_step_of_run:
|
||||
gc.collect() # manually collect a lot of garbage from setup
|
||||
gc.freeze() # immediately freeze all currently surviving objects and exclude them from GC
|
||||
gc.disable() # nuclear intervention here: disable GC entirely except:
|
||||
gc.disable() # nuclear intervention here: disable GC entirely except Exception:
|
||||
elif step % 5000 == 0: # every 5000 steps...
|
||||
gc.collect() # manually collect, just to be safe for very, very long runs
|
||||
|
||||
|
|
|
|||
|
|
@ -468,7 +468,7 @@ while True:
|
|||
if step == 1:
|
||||
gc.collect() # manually collect a lot of garbage from setup
|
||||
gc.freeze() # freeze all currently surviving objects and exclude them from GC
|
||||
gc.disable() # disable GC entirely except:
|
||||
gc.disable() # disable GC entirely except Exception:
|
||||
elif step % 5000 == 0: # every 5000 steps...
|
||||
gc.collect() # manually collect, just to be safe for very long runs
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user