Use of generators for retrieving the session is IMO completely unnecessary (correct me if I'm missing something).
This is not an expensive operation that would benefit from being interrupted early. Getting all sessions and returning a list is not gonna be slower. It will potentially even be faster as I imagine that generators have some overhead.
Use of generators for retrieving the session is IMO completely unnecessary (correct me if I'm missing something).
Iterable[Session]
, there is no way of knowing that the code will fail if trying to iterate sessions twice.