Azure / Azure/azure-functions-host
Python Timer Triggers on the Linux Consumption Plan do not Timeout.
- Dominant language
- C#
- Stars
- 2k
- Forks
- 482
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 38
Description
#### Investigative information
Please provide the following:
- Timestamp:
- Function App version (1.0 or 2.0):2.0
- Function App name:testfinpyfunction
- Function name(s) (as appropriate): TimerTrigger
- Invocation ID: c4128915-9119-4310-8b6b-c8c0210cfc1b
- Region:West Europe
#### Repro steps
Provide the steps required to reproduce the problem:
1. Create a new Python Function App.
2. Add a Timer Trigger (see code below)
3. Add a HTTP Trigger (see code below)
4. Update the Host.json so that the Timeout is 1 minute.
{
"version": "2.0",
"functionTimeout":"00:01:00"
}
#### Expected behavior
Provide a description of the expected behavior.
1. That the Function App should stop the Timer Trigger after 1 minute.
#### Actual behavior
Provide a description of the actual behavior observed.
1. The Timer Trigger doesn't timeout and the restart of the Functions Host will retry this invocation.
06/25/2019 04:23:53.648 PM Function 'Functions.TimerTrigger' initial status: Last='0001-01-01T00:00:00.0000000', Next='2019-06-25T16:05:00.0000000+00:00', LastUpdated='2019-06-24T23:00:00.0084059+00:00'
06/25/2019 04:23:53.653 PM Function 'Functions.TimerTrigger' is past due on startup. Executing now.
06/25/2019 04:23:53.831 PM Executing 'Functions.TimerTrigger' (Reason='Timer fired at 2019-06-25T16:23:53.7032674+00:00', Id=8758c35b-7a71-47a3-89b9-53d3c99c0d8f)
06/25/2019 04:23:53.837 PM Trigger Details: UnscheduledInvocationReason: IsPastDue, OriginalSchedule: 2019-06-25T16:05:00.0000000+00:00
06/25/2019 04:23:53.946 PM Sending invocation id:8758c35b-7a71-47a3-89b9-53d3c99c0d8f
#### Known workarounds
Provide a description of any known workarounds.
No Workarounds exist.
#### Related information
Provide any related information
* Programming language used -Python
* Links to source
* Bindings used - Timer, HTTP
Source
```Timer
import datetime
import logging
import time
import azure.functions as func
async def main(mytimer: func.TimerRequest) -> None:
utc_timestamp = datetime.datetime.utcnow().replace(
tzinfo=datetime.timezone.utc).isoformat()
time.sleep(660)
if mytimer.past_due:
logging.info('The timer is past due!')
logging.info('Python timer trigger function ran at %s', utc_timestamp)
```
```Http
import logging
import azure.functions as func
import time
async def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
time.sleep(660)
name = req.params.get('name')
if not name:
try:
req_body = req.get_json()
except ValueError:
pass
else:
name = req_body.get('name')
if name:
return func.HttpResponse(f"Hello {name}!")
else:
return func.HttpResponse(
"Please pass a name on the query string or in the request body",
status_code=400
)
```
Contributor guide
Research direction
Start with the host.json setting for functionTimeout and the TimerTrigger invocation described in the issue. Reproduce the Python Timer Trigger with the supplied 660-second delay, then compare its behavior with the HTTP Trigger; done means the Timer Trigger stops after the configured one-minute timeout and does not retry the same invocation after host restart.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, python
- Domain
- backend, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100