Skip to content

Commit

Permalink
send task: log delay from when Object was created
Browse files Browse the repository at this point in the history
  • Loading branch information
snarfed committed Sep 18, 2024
1 parent 85b9643 commit 5884be8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -1709,7 +1709,10 @@ def send_task():
if form.get('orig_obj') else None)

# send
logger.info(f'Sending {obj.source_protocol} {obj.type} {obj.key.id()} to {protocol} {url}')
delay = ''
if request.headers.get('X-AppEngine-TaskRetryCount') == '0' and obj.created:
delay = f'({(util.now().replace(tzinfo=None) - obj.created).total_seconds()} s behind)'
logger.info(f'Sending {obj.source_protocol} {obj.type} {obj.key.id()} to {protocol} {url} {delay}')
logger.debug(f' AS1: {json_dumps(obj.as1, indent=2)}')
sent = None
try:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -3199,7 +3199,7 @@ def test_send_task_handler(self):
'orig_obj': note.key.urlsafe(),
'url': 'fake:shared:target',
'user': self.user.key.urlsafe(),
})
}, headers={'X-AppEngine-TaskRetryCount': '0'})
self.assertEqual(200, resp.status_code)

def test_send_task_missing_url(self):
Expand Down

0 comments on commit 5884be8

Please sign in to comment.