mosbth / irc2phpbb

IRC bot, now lives on Discord bur remains its power to visit IRC whenever it wants.
12 stars 16 forks source link

Close file on open OR move to memory #47

Closed NiklasAurora closed 2 weeks ago

NiklasAurora commented 6 years ago

https://github.com/mosbth/irc2phpbb/blob/be7ec4754161243143e67fbf370bdc1d96d09f79/marvin_general_actions.py#L81-L90

This code should be rewritten to either use WITH or to close the file after use.

Another solution is to have the date loaded in memory since Marvin is always running, however, this means he could says good morning twice on the days he's restarted or crashes.

SpaceLenore commented 6 years ago

submitted PR #50 which fixes this

kh31d4r commented 6 years ago

I would say it fixes some of the problems, but I think marvin will still crash (or at least leak resources) if we get an IOError for any reason that is not fixed by opening the file again in write mode.

SpaceLenore commented 6 years ago

good point, and as you wrote in the irc chat about switching to storing it in memory and not saying good morning the first day is probably the most practical solution. I'll re-write it and submit a new PR