我实际上遇到了与post类似的问题。我的应用程序运行正常10分钟,但在这段时间过后我总是遇到这种错误:
E 2014-11-20 12:10:19.516 Traceback (most recent call last):
E 2014-11-20 12:10:19.516 File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/app_logging.py", line 79, in emit
E 2014-11-20 12:10:19.516 logservice.write(message)
E 2014-11-20 12:10:19.516 File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/logservice/logservice.py", line 391, in write
E 2014-11-20 12:10:19.516 logs_buffer().write(message)
E 2014-11-20 12:10:19.516 File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/logservice/logservice.py", line 1171, in write
E 2014-11-20 12:10:19.516 return self._write(line)
E 2014-11-20 12:10:19.516 File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/logservice/logservice.py", line 1188, in _write
E 2014-11-20 12:10:19.516 self._autoflush()
E 2014-11-20 12:10:19.516 File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/logservice/logservice.py", line 1256, in _autoflush
E 2014-11-20 12:10:19.516 self._flush()
E 2014-11-20 12:10:19.516 File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/logservice/logservice.py", line 1239, in _flush
E 2014-11-20 12:10:19.516 apiproxy_stub_map.MakeSyncCall('logservice', 'Flush', request, response)
E 2014-11-20 12:10:19.516 File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 95, in MakeSyncCall
E 2014-11-20 12:10:19.516 return stubmap.MakeSyncCall(service, call, request, response)
E 2014-11-20 12:10:19.516 File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 329, in MakeSyncCall
E 2014-11-20 12:10:19.516 rpc.CheckSuccess()
E 2014-11-20 12:10:19.516 File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/apiproxy_rpc.py", line 134, in CheckSuccess
E 2014-11-20 12:10:19.516 raise self.exception
E 2014-11-20 12:10:19.516 CancelledError: The API call logservice.Flush() was explicitly cancelled.
E 2014-11-20 12:10:19.516 Logged from file wsgi.py, line 279
我通过使用cron作业来调用页面。然后,此页面将启动任务队列(推送)。在这里,我试图覆盖autoflush设置,但无法达到任何改进。
import webapp2
from bdmodel import *
from indexObserver import *
import datetime
import indexObserver
from google.appengine.api.labs import taskqueue
from google.appengine.api import logservice
logservice.AUTOFLUSH_ENABLED = True
logservice.AUTOFLUSH_EVERY_SECONDS = None
logservice.AUTOFLUSH_EVERY_BYTES = None
logservice.AUTOFLUSH_EVERY_LINES = 100
class ClosingValueHandler(webapp2.RequestHandler):
def get(self):
self.response.write('<p>Closing Value</p>')
taskqueue.add(url="/closing_value_queue")
#result = detectClosingValue()
#logging.info('detectClosingValue returned %s' % str(result))
class ClosingValueWorker(webapp2.RequestHandler):
def post(self):
result = detectClosingValue()
logging.info('detectClosingValue returned %s' % str(result))
在此队列内部有一个递归方法,在到目前为止尚未达到最终状态的情况下调用自身。正如您所看到的,我已经尝试过手动清除日志但没有任何影响。有谁知道该怎么办?提前谢谢!
def detectClosingValue():
logging.info('detectClosingValue started')
query = "SELECT * FROM DaxValue WHERE date = DATE('%s')" % str(datetime.datetime.now().date())
q = db.GqlQuery(query)
daxValue = q.get()
if not daxValue.isTradingDay:
return False
else:
previous = getLatestValue()[0]
time.sleep(5)
i = 1
while i < 10:
logservice.flush()
logging.info("retrieved close %d value at %s" % (i, str(previous)))
if previous != getLatestValue()[0]:
time.sleep(25)
detectClosingValue()
i += 1
time.sleep(10)
daxValue = q.get()
daxValue.close = getLatestValue()[0]
daxValue.high = getLatestValue()[3]
daxValue.low = getLatestValue()[2]
daxValue.opn = getLatestValue()[1]
daxValue.popDate = datetime.datetime.now()
daxValue.put()
logging.info("stored close value at %s" % str(daxValue.close))
return True
答案 0 :(得分:1)
根据this post,当引发DeadlineExceededErrors
队列中的日志时会发生错误。
如果你的应用程序运行的时间恰好是10分钟,请尝试将其运行一点点,例如9:55分钟,以便正确刷新日志。