Skip to content

Error in Python get_remaining_time_in_millis #63

@subssn21

Description

@subssn21

When you make a call to context.get_remaining_time_in_millis

In the local dev you get the following traceback:
Error: unsupported operand type(s) for -: 'str' and 'int'
File "/Users/dramus/chartflow/node_modules/sst/support/python-runtime/runtime.py", line 101, in
result = handler(event, context)

 File "/Users/dramus/.virtualenvs/chartflow/lib/python3.13/site-packages/datadog_lambda/wrapper.py", line 239, in __call__
"""Executes when the wrapped function gets called"""

 File "/Users/dramus/.virtualenvs/chartflow/lib/python3.13/site-packages/ddtrace/contrib/internal/aws_lambda/patch.py", line 117, in __call__
self._before(args, kwargs)
~~~~~~~~~~~~^^^^^^^^^^^^^^

 File "/Users/dramus/.virtualenvs/chartflow/lib/python3.13/site-packages/ddtrace/contrib/internal/aws_lambda/patch.py", line 145, in _before
self.timeoutChannel._start()
~~~~~~~~~~~~~~~~~~~~~~~~~~^^

 File "/Users/dramus/.virtualenvs/chartflow/lib/python3.13/site-packages/ddtrace/contrib/internal/aws_lambda/patch.py", line 74, in _start
remaining_time_in_millis = self.context.get_remaining_time_in_millis()

 File "/Users/dramus/chartflow/node_modules/sst/support/python-runtime/runtime.py", line 38, in get_remaining_time_in_millis
return int(max(self.deadline_ms - int(round(time() * 1000)), 0))
               ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~

The reason is that the header returns a string and is assigned to self.deadline_ms without being coerced back into an int.

Pull Request #62 fixes this by coercing the header value back into an int that is should already be in

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions