내가 auto_now_add
와 auto_now
와 DateTimePropterty
로 date_created
및 date_updated
를 포함 일부 필드와 Conversation
라는 모델을했습니다.GAE 파이썬 NDB put_async 문제
put()
메서드를 사용하여 모델을 업데이트하면 date_updated
필드가 업데이트되고 있습니다. 그러나 put_async
메서드를 사용하면 date_updated
필드의 값이 업데이트되지 않습니다.
또한 파이썬의 unittest.Testcase
을 사용하여 테스트 케이스를 작성했는데 정상적으로 작동합니다.
참고 : put_async().get_result()
을 사용할 때 작동합니다.
샘플 모델 클래스 :
class Conversation(ndb.Model):
participants = ndb.StringProperty(repeated=True)
conversation_name = ndb.StringProperty()
date_created = ndb.DateTimeProperty(required=True, auto_now_add=True)
date_updated = ndb.DateTimeProperty(required=True, auto_now=True)
@staticmethod
def update_conversation_date_by_id(conversation_id):
conversation = Conversation.get_by_id(conversation_id) if conversation_id else None
if conversation is None:
raise CannotFindEntity("Given conversation_id is not found")
else:
conversation.put_async().get
return conversation
[ndb async가 응용 프로그램 요청이 완료된 후에 실행할 수 있습니까?] (http://stackoverflow.com)/questions/11621313/is-ndb-async-guarantee-after-after-application-request-has-finished) –