@@ -610,6 +610,7 @@ def full_build(self):
610610 def run (self , http : urllib3 .PoolManager ) -> bool :
611611 """Build and publish a Python doc, for a language, and a version."""
612612 start_time = perf_counter ()
613+ start_timestamp = dt .now (tz = timezone .utc ).replace (microsecond = 0 )
613614 logging .info ("Running." )
614615 try :
615616 self .cpython_repo .switch (self .version .branch_or_tag )
@@ -619,7 +620,10 @@ def run(self, http: urllib3.PoolManager) -> bool:
619620 self .build_venv ()
620621 self .build ()
621622 self .copy_build_to_webroot (http )
622- self .save_state (build_duration = perf_counter () - start_time )
623+ self .save_state (
624+ build_start = start_timestamp ,
625+ build_duration = perf_counter () - start_time ,
626+ )
623627 except Exception as err :
624628 logging .exception ("Badly handled exception, human, please help." )
625629 if sentry_sdk :
@@ -921,7 +925,7 @@ def load_state(self) -> dict:
921925 except (KeyError , FileNotFoundError ):
922926 return {}
923927
924- def save_state (self , build_duration : float ):
928+ def save_state (self , build_start : dt , build_duration : float ):
925929 """Save current CPython sha1 and current translation sha1.
926930
927931 Using this we can deduce if a rebuild is needed or not.
@@ -932,17 +936,23 @@ def save_state(self, build_duration: float):
932936 except FileNotFoundError :
933937 states = tomlkit .document ()
934938
935- state = {}
936- state ["cpython_sha" ] = self .cpython_repo .run ("rev-parse" , "HEAD" ).stdout .strip ()
939+ key = f"/{ self .language .tag } /{ self .version .name } /"
940+ state = {
941+ "last_build_start" : build_start ,
942+ "last_build_duration" : round (build_duration , 0 ),
943+ "cpython_sha" : self .cpython_repo .run ("rev-parse" , "HEAD" ).stdout .strip (),
944+ }
937945 if self .language .tag != "en" :
938946 state ["translation_sha" ] = self .translation_repo .run (
939947 "rev-parse" , "HEAD"
940948 ).stdout .strip ()
941- state ["last_build" ] = dt .now (timezone .utc )
942- state ["last_build_duration" ] = build_duration
943- states [f"/{ self .language .tag } /{ self .version .name } /" ] = state
949+ states [key ] = state
944950 state_file .write_text (tomlkit .dumps (states ), encoding = "UTF-8" )
945951
952+ tbl = tomlkit .inline_table ()
953+ tbl |= state
954+ logging .info ("Saved new rebuild state for %s: %s" , key , tbl .as_string ())
955+
946956
947957def symlink (
948958 www_root : Path ,
0 commit comments