I have a google cloud function triggered by a topic pubsub.
Most of the times, everything works fine like this:
2021-11-06 15:12:38.830 GMT vote_stage oga5hymuzx4p Function execution started
2021-11-06 15:13:45.392 GMT vote_stage oga5hymuzx4p Function execution took 66563 ms, finished with status: 'ok'
But unfortunately, once in twenty, i can only see this:
2021-11-06 15:08:45.139 GMT vote_stage rvfnd4wo5nwd Function execution started
How is this possible that there is no exit log ?
Below, the code of the function:
def vote_stage(event, context):
assert context == context
call_datetime = reusable.time.get_now()
game_id = event['attributes']['game_id']
logger.info(f'start, game_id={game_id}')
game = build_game(game_id)
resp = ut.exceptions.ExceptionsHandler(game).handle_vote_stage_exceptions()
if resp:
logger.info(f'exception, game_id={game_id}')
return resp
game.dict['vote_stage_last_trigger'] = reusable.time.get_now()
ut.firestore.FirestoreEditor(game).set_game(merge=True)
while True:
game = build_game(game_id)
ut.slack.SlackOperator(game).update_vote_stage_lower()
c1 = len(game.frozen_guessers) == 1
c2 = game.time_left_to_vote <= 0
c3 = not game.remaining_potential_voters
if c1 or c2 or c3:
game.dict['frozen_voters'] = deepcopy(game.dict['voters'])
game.dict['vote_stage_over'] = True
ut.firestore.FirestoreEditor(game).set_game(merge=True)
game.stage_triggerer.trigger_pre_result_stage()
logger.info(f'pre_result_stage triggered, game_id={game_id}')
return make_response('', 200)
if ut.time.datetime1_minus_datetime2(
reusable.time.get_now(),
call_datetime) > game.self_trigger_threshold:
game.stage_triggerer.trigger_vote_stage()
logger.info(f'vote_stage self-triggered, game_id={game_id}')
return make_response('', 200)
time.sleep(game.refresh_interval)
Here, game.self_trigger_threshold = 60s and game.refresh_interval = 9s. The vote_stage function has a timeout of 540s.
The method game.stage_triggerer.trigger_pre_result_stage() publishes a message to a topic "topic_pre_result_stage" which triggers the "pre_result_stage" cloud function.
The method game.stage_triggerer.trigger_vote_stage() publishes a message to a topic "topic_vote_stage" which triggers the "vote_stage" cloud function.
The only inner log i find is:
2021-11-06 15:08:49.594 GMT vote_stage rvfnd4wo5nwd 2021-11-06 15:08:49,594 - INFO - start, game_id=20211106_150714&T01LTPERV4Z&C02EKL5PQAX&U01LFAZNKPV&2694551026434.1707796879169.ce017050e1e74e97332c2a04d4b19c08