@@ -778,31 +778,28 @@ async def _end_of_season_poller(self):
778778 pass
779779 except (Exception , BaseException ) as exception :
780780 self .dispatch ("event_error" , exception )
781- return await self ._maintenance_poller ()
781+ return await self ._end_of_season_poller ()
782782
783783 async def _maintenance_poller (self ):
784784 # pylint: disable=broad-except, protected-access
785785 maintenance_start = None
786786 try :
787787 while self .loop .is_running ():
788- await self ._in_maintenance_event .wait ()
789-
790- if maintenance_start is None :
791- maintenance_start = datetime .utcnow ()
792- self .dispatch ("maintenance_start" )
793- await asyncio .sleep (60 )
794-
795788 try :
796- player = await self .get_player ("#JY9J2Y99" ) # this will raise if API is in maintenance
797- await asyncio .sleep (player ._response_retry ) # wait until fresh object available
798- # re-run again, this should raise Maintenance because API cache layer has expired
799- await self .get_player ("#JY9J2Y99" )
789+ player = await self .get_player ("#JY9J2Y99" )
790+ await asyncio .sleep (player ._response_retry + 1 )
800791 except (Maintenance , Exception ):
801- await asyncio .sleep (5 )
792+ if maintenance_start is None :
793+ self ._in_maintenance_event .clear ()
794+ maintenance_start = datetime .utcnow ()
795+ self .dispatch ("maintenance_start" )
796+
797+ await asyncio .sleep (15 )
802798 else :
803- self ._in_maintenance_event .clear ()
804- self .dispatch ("maintenance_completion" , maintenance_start )
805- maintenance_start = None
799+ if maintenance_start is not None :
800+ self ._in_maintenance_event .set ()
801+ self .dispatch ("maintenance_completion" , maintenance_start )
802+ maintenance_start = None
806803
807804 except asyncio .CancelledError :
808805 pass
@@ -815,8 +812,7 @@ async def _war_updater(self):
815812 try :
816813 while self .loop .is_running ():
817814 await asyncio .sleep (DEFAULT_SLEEP )
818- if self ._in_maintenance_event .is_set ():
819- continue # don't run if we're hitting maintenance errors.
815+ await self ._in_maintenance_event .wait () # don't run if we're hitting maintenance errors.
820816
821817 self .dispatch ("war_loop_start" , self .war_loops_run )
822818
@@ -848,8 +844,7 @@ async def _clan_updater(self):
848844 try :
849845 while self .loop .is_running ():
850846 await asyncio .sleep (DEFAULT_SLEEP )
851- if self ._in_maintenance_event .is_set ():
852- continue # don't run if we're hitting maintenance errors.
847+ await self ._in_maintenance_event .wait () # don't run if we're hitting maintenance errors.
853848
854849 self .dispatch ("clan_loop_start" , self .clan_loops_run )
855850 tasks = [
@@ -875,8 +870,7 @@ async def _player_updater(self):
875870 try :
876871 while self .loop .is_running ():
877872 await asyncio .sleep (DEFAULT_SLEEP )
878- if self ._in_maintenance_event .is_set ():
879- continue # don't run if we're hitting maintenance errors.
873+ await self ._in_maintenance_event .wait () # don't run if we're hitting maintenance errors.
880874
881875 self .dispatch ("player_loop_start" , self .player_loops_run )
882876 tasks = [
0 commit comments