Alexander Sysoev
Alexander Sysoev

Reputation: 835

Cron jobs ended with 504 Gateway Timeout after 60s on GAE with python 3.7

I created a new project with google app engine using python 3.7 and django using google template . All cron jobs failed with 504 request timeout. Also, I tried new task queue using google cloud tasks, but this request also failed after 60s.

App.yaml

# [START django_app]
runtime: python37

handlers:
- url: /assets
  static_dir: assets/
- url: /.*
  script: auto

instance_class: F2
automatic_scaling:
  min_idle_instances: 1
  max_idle_instances: automatic

Cron.yaml

cron:
- description: cron eth price
  url: /cron/
  schedule: every 5 mins

Cron view

class CronView(View):
    def get(self, request, *args, **kwargs):
        from time import sleep
        sleep(240)
        return HttpResponse('')

Upvotes: 2

Views: 824

Answers (1)

Dan Cornilescu
Dan Cornilescu

Reputation: 39834

This is just a theory :)

There seems to be a bit of a conflict in the documentation.

On one hand from (2nd generation standard environment) Scheduling Jobs with cron.yaml:

A cron job will invoke a URL, using an HTTP GET request, at a given time of day. An HTTP request invoked by cron can run for up to 60 minutes, but is subject to the same limits as other HTTP requests.

By comparison, for the 1st generation standard environment, from Deadlines:

The cron timeout deadline depends on the instance class and scaling type that is configured for your app:

Automatic scaling

Timeout is about 10 minutes.

On the other hand from the Deadline row in the Instance scaling table (consistent with the 1st generation info, but probably just a documentation bug given that the task queue support is actually different):

Automatic scaling

60-second deadline for HTTP requests, 10-minute deadline for task queue tasks.

... and, of course, keeping in mind that the cron requests are HTTP requests, not task queue tasks.

Upvotes: 1

Related Questions