0

I am new to Google App Engine. The APScheduler works perfectly fine for a simple code in python. But when uploaded to the GAE, it shows continuous loading with no response.

import webapp2
import sys
import time
def my_job(text):
    self.response.out.write(text)

sys.path.insert(0, 'libs')

from bs4 import BeautifulSoup
from apscheduler.scheduler import Scheduler
sched = Scheduler()

class MainPage(webapp2.RequestHandler):
    def get(self):
    html = "<html><p>Para 1<p>Para 2<blockquote>Quote 1<blockquote>Quote 2"
soup = BeautifulSoup(html)
self.response.out.write(soup.prettify())
self.response.out.write(time.strftime("%d/%m/%Y"))
self.response.out.write(time.strftime("%H:%M:%S"))

job = sched.add_date_job(my_job, '2015-03-5 16:13:05', ['Hello World'])#
sched.start()
while True:
  sleep(1)
app = webapp2.WSGIApplication([('/', MainPage)], debug=True)
aakash
  • 13
  • 3

2 Answers2

1

As the other person pointed out the while true: sleep will cause you problems. However your problems go deeper than that.

APScheduler is not an appropriate tool for appengine out of the box, unless you are running it under compute engine.

Appengine front end requests can only run for a max of 60 seconds. Appengine has it's own facility called task queues and cron.

APScheduler would need to be modified to use these underlying services to be of any use on appengine.

Tim Hoffman
  • 12,976
  • 1
  • 17
  • 29
0

The problem in your code is:

while True:
  sleep(1)

This will cause your request to hang forever and never respond.

svpino
  • 1,864
  • 17
  • 18