Skip to content

Good (and simple) way to add persistence when recording events? #6875

Answered by aaossa
aaossa asked this question in Q&A
Discussion options

You must be logged in to vote

Seems that using a producer/consumer approach using asyncio.Queue (see this SO answer) is a good enough approach. My consumer would receive an event to be logged and then open, write and close the output file, while the producer would be the event handler (for example, on_message). This seems like a good idea at the moment, so I'll try to implement it. I'll leave this discussion open for a while in case some better approach appears (or this one fails).

PD: Just to be clear, I need this approach to avoid inconsistencies in the output file and access the file in a thread-safe manner

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@aaossa
Comment options

Answer selected by aaossa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant