在我的映射器中,上下文被返回为 NULL
class DeleteOldObservationsMapper(object):
"""Mapper for deleting old observations."""
def __init__(self):
logging.info('DeleteOldObservationsMapper init')
ctx = mapreduce.context.get()
when = ctx.mapreduce_spec.mapper.params.get('before_timestamp_seconds')
assert when
self.before_datetime = datetime.datetime.utcfromtimestamp(when)
logging.info('before_datetime %s', self.before_datetime)
这是错误跟踪:
ERROR 2013-05-24 16:03:38,662 webapp2.py:1552] 'NoneType' object has no attribute
'mapreduce_spec'
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1535, in __call__
rv = self.handle_exception(request, response, e)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1529, in __call__
rv = self.router.dispatch(request, response)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1102, in __call__
return handler.dispatch()
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
File "/Users/leoromanovsky/code/adapt/server/mapreduce/base_handler.py", line 66, in post
self.handle()
File "/Users/leoromanovsky/code/adapt/server/mapreduce/handlers.py", line 320, in handle
tstate = model.TransientShardState.from_request(self.request)
File "/Users/leoromanovsky/code/adapt/server/mapreduce/model.py", line 993, in from_request
handler = mapreduce_spec.mapper.handler
File "/Users/leoromanovsky/code/adapt/server/mapreduce/model.py", line 618, in get_handler
return util.handler_for_name(self.handler_spec)
File "/Users/leoromanovsky/code/adapt/server/mapreduce/util.py", line 149, in handler_for_name
return getattr(resolved_name.im_class(), resolved_name.__name__)
File "/Users/leoromanovsky/code/adapt/server/jobs.py", line 22, in __init__
when = ctx.mapreduce_spec.mapper.params.get('before_timestamp_seconds')
AttributeError: 'NoneType' object has no attribute 'mapreduce_spec'