在GAE中使用memcache时,我很少注意到这种奇怪的行为.我在memcache中设置了一个值,当我尝试检索相同的值时,我得到None而不是原始值.memcache值在这么短的时间内不能过期.我确保在memcache中设置值时返回True.还有什么可以导致memcache值丢失?这是一种常见的系统行为吗?
代码示例:
用于设置值
cache_set = memcache.set(matrix_name+'-'+str(m)+","+str(n),data[n],namespace=uuid)
while cache_set == False :
sleep(0.1)
logging.error(" Cache Set failed. Retrying for %s %s",matrix_name,str[m,n])
cache_set = memcache.set(matrix_name+'-'+str(m)+","+str(n),data[n],namespace=uuid)
Run Code Online (Sandbox Code Playgroud)
用于检索值
memcache.get(matrix_name+'-'+str(m)+","+str(n),namespace=uuid)
Run Code Online (Sandbox Code Playgroud) 我经常收到此应用程序错误.这是什么意思 ?
File "/base/data/home/apps/0xxopdp/10.347467753731922836/matrices.py", line 215, in insert_into_db
obj.put()
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/db/__init__.py", line 895, in put
return datastore.Put(self._entity, config=config)
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/datastore.py", line 404, in Put
return _GetConnection().async_put(config, entities, extra_hook).get_result()
File "/base/python_runtime/python_lib/versions/1/google/appengine/datastore/datastore_rpc.py", line 601, in get_result
self.check_success()
File "/base/python_runtime/python_lib/versions/1/google/appengine/datastore/datastore_rpc.py", line 572, in check_success
rpc.check_success()
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 502, in check_success
self.__rpc.CheckSuccess()
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/apiproxy_rpc.py", line 126, in CheckSuccess
raise self.exception
ApplicationError: ApplicationError: 5
Run Code Online (Sandbox Code Playgroud)
我确实多次调用数据存储区.是什么导致了这个问题
有人可以解释一下Google App Engine中的Always on功能吗?它有用吗?将举例说明示例.
Always on功能是否也适用于任务队列?
有没有办法在执行任务时处理任何软截止日期?执行10分钟后抛出DeadlineExceededError,之后几秒钟我就会做一些事情.我想在任务终止之前清理一些事情并创建一个新任务.这可能需要几秒钟.有没有办法通过捕获大约9分钟的任何异常来做到这一点.我知道我可以在9分钟后手动抛出异常.但这可以由GAE自动完成吗?
class FillMtxHandler():
def post(self,index,user,seqlen):
try :
FillMtx(index,user,seqlen)
except DeadlineExceededError:
deferred.defer(self.post,index,user,seqlen)
Run Code Online (Sandbox Code Playgroud)
以上是我的代码.index是一个列表,从0开始.它将在FillMtx中递增.一旦超过截止日期,就会抛出错误,我想继续从索引最后增加的位置开始.我收到以下错误
The API call taskqueue.BulkAdd() was explicitly cancelled.
Traceback (most recent call last):
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 517, in __call__
handler.post(*groups)
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/deferred/deferred.py", line 258, in post
run(self.request.body)
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/deferred/deferred.py", line 124, in run
return func(*args, **kwds)
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/deferred/deferred.py", line 166, in invoke_member
return getattr(obj, membername)(*args, **kwargs)
File "/base/data/home/apps/0xxopdp/3.347813391084738922/fillmtx.py", line 204, in post
deferred.defer(self.post,index,user,seqlen)
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/deferred/deferred.py", line 241, in defer
return task.add(queue, transactional=transactional)
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/taskqueue/taskqueue.py", line 688, in add
return …
Run Code Online (Sandbox Code Playgroud) 我使用批量下载从数据存储区下载数据(超过1 GB).突然,我的互联网停止工作,下载过程停在中间.我想从它停止的地方恢复.当我尝试时,我收到以下错误
File "/Users/FYP/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/datastore_types.py", line 156, in ValidateString
(name, value, typename(value)))
BadArgumentError: kind should be a string; received 3 (a int):
[INFO ] [WorkerThread-2] Backing off due to errors: 1.0 seconds
[INFO ] An error occurred. Shutting down...
[ERROR ] Error in WorkerThread-0: kind should be a string; received 3 (a int):
Run Code Online (Sandbox Code Playgroud)
这是我下载数据的代码
appcfg.py download_data --config_file=bulkloader.yaml --batch_size=200 --filename=final80_2.csv
--kind=TasksTime1 --url=http://abc.appspot.com/_ah/remote_api --rps_limit=40
--db_filename=bulkloader-progress-20110429.141103 --result_db_filename=bulkloader-results-20110429.141103
Run Code Online (Sandbox Code Playgroud)
如何解决问题?
我使用remote_api连接到我的应用程序.当我尝试使用此导入我的模型时
from models import SimpleCounterShard
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
ImportError: No module named models
Run Code Online (Sandbox Code Playgroud)
我试着寻找解决方案,这似乎与PYTHONPATH有关.谁能告诉我如何解决这个问题?我正在使用Mac.
class Matrix(db.Model):
values = db.ListProperty()
obj = Matrix()
wx = [[1,0],[0,1]]
obj.put()
Run Code Online (Sandbox Code Playgroud)
如何在数据存储区内存储wx矩阵?
有没有办法禁用失败的任务的重试选项?它不可能在queue.yaml中执行此操作
retry_parameters:
task_retry_limit: 0
Run Code Online (Sandbox Code Playgroud)
还有其他选项可以禁用重试吗?
目前我有在后台运行的任务.任务完成后,我需要显示输出.我如何在Google App Engine中执行此操作?
一旦任务完成,我唯一能做的就是创建另一个应该显示输出的任务或者还有其他方法吗?
我有n个并行任务在运行.完成所有这些任务后,我想创建另一个任务.做这个的最好方式是什么 ?由于数据存储操作较慢,我使用了memcache.每个任务完成后,我一直将计数器递增1.我一直在检查柜台n.由于memcache不可靠,有时会丢失计数器值.还有其他方法吗?
如何在Google应用引擎中存储超过10 MB的数据?来自数据存储区的put()只允许1 MB.我是否需要将数据分成每个1MB的块并存储?或者还有其他方法吗?