来自https://developers.google.com/appengine/articles/deferred的这段代码会是线程安全的吗?(可与runtime: python27
+一起使用threadsafe: yes
)
class GuestbookUpdater(Mapper):
KIND = Greeting
def map(self, entity):
if entity.content.lower().find('foo') != -1:
entity.content += ' Bar!'
return ([entity], [])
return ([], [])
mapper = MyMapper()
deferred.defer(mapper.run)
另外,不应该读
class GuestbookUpdater(Mapper):
KIND = Greeting
def map(self, entity):
if entity.content.lower().find('foo') != -1:
entity.content += ' Bar!'
return ([entity], [])
return ([], [])
mapper = GuestbookUpdater()
deferred.defer(mapper.run)