mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-22 04:01:27 +00:00
fix: free unused journal.Reader instances
This commit is contained in:
parent
7fe0f27f52
commit
3ee5c3bcc0
|
@ -27,5 +27,6 @@ async def log_stream() -> AsyncGenerator[LogEntry, None]:
|
|||
yield LogEntry(entry)
|
||||
except Exception:
|
||||
asyncio.get_event_loop().remove_reader(j)
|
||||
j.close()
|
||||
return
|
||||
queue.task_done()
|
||||
|
|
|
@ -42,6 +42,8 @@ def get_paginated_logs(
|
|||
events = get_events_from_journal(j, limit, lambda j: j.get_previous())
|
||||
events.reverse()
|
||||
|
||||
j.close()
|
||||
|
||||
return events
|
||||
elif up_cursor is None and down_cursor is not None:
|
||||
j.seek_cursor(down_cursor)
|
||||
|
@ -50,6 +52,8 @@ def get_paginated_logs(
|
|||
events = get_events_from_journal(j, limit, lambda j: j.get_previous())
|
||||
events.reverse()
|
||||
|
||||
j.close()
|
||||
|
||||
return events
|
||||
elif up_cursor is not None and down_cursor is None:
|
||||
j.seek_cursor(up_cursor)
|
||||
|
@ -57,8 +61,12 @@ def get_paginated_logs(
|
|||
|
||||
events = get_events_from_journal(j, limit, lambda j: j.get_next())
|
||||
|
||||
j.close()
|
||||
|
||||
return events
|
||||
else:
|
||||
j.close()
|
||||
|
||||
raise NotImplementedError(
|
||||
"Pagination by both up_cursor and down_cursor is not implemented"
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue