Django の ORM を使用して、Db から新しく追加されたエントリを取得し、それらをメッセージング キューに渡しています。私は無限 while ループでこれを行っています。すべてのループ反復の問題 このスクリプトの実行中にエントリを追加/削除/編集した場合でも、同じクエリセットを取得しています。
コードは次のようになります。
while True :
sleep(10 seconds)
# Below is the problem line, I get the same query-set every time in new_objects
# even when I have added/deleted/edited entries while this daemon is running.
new_objects = Model.objects.filter(some condition)
# Process new_objects and send them to MQ
.
. and so on
各反復で最新のデータを反映するにはどうすればよいですか?