def transitioning_out_activity_was_freed( self, can_show_ad_on_death: bool) -> None: """(internal)""" from ba._apputils import garbage_collect # Since things should be generally still right now, it's a good time # to run garbage collection to clear out any circular dependency # loops. We keep this disabled normally to avoid non-deterministic # hitches. garbage_collect() with _ba.Context(self): if can_show_ad_on_death: _ba.app.ads.call_after_ad(self.begin_next_activity) else: _ba.pushcall(self.begin_next_activity)
def __del__(self) -> None: from ba._apputils import garbage_collect, call_after_ad # If the activity has been run then we should have already cleaned # it up, but we still need to run expire calls for un-run activities. if not self._expired: with _ba.Context('empty'): self._expire() # Since we're mostly between activities at this point, lets run a cycle # of garbage collection; hopefully it won't cause hitches here. garbage_collect(session_end=False) # Now that our object is officially gonna be dead, tell the session it # can fire up the next activity. if self._transitioning_out: session = self._session() if session is not None: with _ba.Context(session): if self.can_show_ad_on_death: call_after_ad(session.begin_next_activity) else: _ba.pushcall(session.begin_next_activity)