Using pymongo tailable cursors dies on empty collections
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game Looping
--
Chapters
00:00 Question
02:28 Accepted answer (Score 1)
02:56 Thank you
--
Full question
https://stackoverflow.com/questions/1032...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #mongodb #pymongo
#avk47
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game Looping
--
Chapters
00:00 Question
02:28 Accepted answer (Score 1)
02:56 Thank you
--
Full question
https://stackoverflow.com/questions/1032...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #mongodb #pymongo
#avk47
ACCEPTED ANSWER
Score 1
This is known behavior, and the 2 loops "solution" is the accepted practice to work around this case. In the case that the collection is empty, rather than immediately retrying and entering a tight loop as you suggest, you can sleep for a short time (especially if you expect that there will soon be data to tail).