Skip to content

Commit

Permalink
receive task: log delay from when Object was created
Browse files Browse the repository at this point in the history
for #1308
  • Loading branch information
snarfed committed Sep 17, 2024
1 parent 4587dc0 commit 85b9643
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 @@ -829,7 +829,10 @@ def receive(from_cls, obj, authed_as=None, internal=False):

pruned = {k: v for k, v in obj.as1.items()
if k not in ('contentMap', 'replies', 'signature')}
logger.info(f'Receiving {from_cls.LABEL} {obj.type} {id} AS1: {json_dumps(pruned, indent=2)}')
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'Receiving {from_cls.LABEL} {obj.type} {id} {delay} AS1: {json_dumps(pruned, indent=2)}')

# does this protocol support this activity/object type?
from_cls.check_supported(obj)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -2958,7 +2958,7 @@ def test_receive_task_handler(self):
resp = self.post('/queue/receive', data={
'obj': obj.key.urlsafe(),
'authed_as': 'fake:other',
})
}, headers={'X-AppEngine-TaskRetryCount': '0'})
self.assertEqual(204, resp.status_code)
obj = Object.get_by_id('fake:post#bridgy-fed-create')
self.assertEqual('ignored', obj.status)
Expand Down

0 comments on commit 85b9643

Please sign in to comment.