mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-22 12:11:26 +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)
|
yield LogEntry(entry)
|
||||||
except Exception:
|
except Exception:
|
||||||
asyncio.get_event_loop().remove_reader(j)
|
asyncio.get_event_loop().remove_reader(j)
|
||||||
|
j.close()
|
||||||
return
|
return
|
||||||
queue.task_done()
|
queue.task_done()
|
||||||
|
|
|
@ -42,6 +42,8 @@ def get_paginated_logs(
|
||||||
events = get_events_from_journal(j, limit, lambda j: j.get_previous())
|
events = get_events_from_journal(j, limit, lambda j: j.get_previous())
|
||||||
events.reverse()
|
events.reverse()
|
||||||
|
|
||||||
|
j.close()
|
||||||
|
|
||||||
return events
|
return events
|
||||||
elif up_cursor is None and down_cursor is not None:
|
elif up_cursor is None and down_cursor is not None:
|
||||||
j.seek_cursor(down_cursor)
|
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 = get_events_from_journal(j, limit, lambda j: j.get_previous())
|
||||||
events.reverse()
|
events.reverse()
|
||||||
|
|
||||||
|
j.close()
|
||||||
|
|
||||||
return events
|
return events
|
||||||
elif up_cursor is not None and down_cursor is None:
|
elif up_cursor is not None and down_cursor is None:
|
||||||
j.seek_cursor(up_cursor)
|
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())
|
events = get_events_from_journal(j, limit, lambda j: j.get_next())
|
||||||
|
|
||||||
|
j.close()
|
||||||
|
|
||||||
return events
|
return events
|
||||||
else:
|
else:
|
||||||
|
j.close()
|
||||||
|
|
||||||
raise NotImplementedError(
|
raise NotImplementedError(
|
||||||
"Pagination by both up_cursor and down_cursor is not implemented"
|
"Pagination by both up_cursor and down_cursor is not implemented"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue