Added cache cleaning function, although it's almost useless

This commit is contained in:
Frisk 2018-06-22 15:21:28 +02:00
parent a612be1553
commit 941e7de3a7
No known key found for this signature in database
GPG key ID: 0E9A7D3C0A01586C
2 changed files with 4 additions and 5 deletions

View file

@ -50,7 +50,7 @@ Translators:
* JSBM for French translation
### Other ###
Script seem to use about 17MB of RAM and negligible amount of CPU when fetching changes.
Script seem to use about 10-17MB of RAM and negligible amount of CPU when fetching changes.
Script does not log bot actions by default.
"I GoT "Unable to process the event" mESSage!!! WHaT HApND?" - it means there is some kind of action that does not have a template in the script, please [create a ticket](https://gitlab.com/piotrex43/RcGcDw/issues/new?issue%5Bassignee_id%5D=&issue%5Bmilestone_id%5D=) with information on what wiki this error ocurred and when.
[Here](https://framapic.org/rVFQD0NQVcok/Ue1SVHHM0e4V.png) is a screenshot of how few embeds look like.

View file

@ -618,6 +618,8 @@ class recent_changes_class(object):
if(time.time() - self.last_downtime)>1800 and self.check_connection(): #check if last downtime happened within 30 minutes, if yes, don't send a message
send(_("{wiki} seems to be down or unreachable.").format(wiki=settings["wikiname"]), _("Connection status"), settings["avatars"]["connection_failed"])
self.last_downtime = time.time()
def clear_cache(self):
self.map_ips = {}
recent_changes = recent_changes_class()
recent_changes.fetch(amount=settings["limitrefetch" ] if settings["limitrefetch"] != -1 else settings["limit"])
@ -631,11 +633,8 @@ if settings["overview"]:
diff = (datetime.datetime.now().hour - datetime.datetime.utcnow().hour, datetime.datetime.now().minute - datetime.datetime.utcnow().minute)
tim = (ovUTC_time[0]+diff[0], ovUTC_time[1]+diff[1])
schedule.every().day.at("{}:{}".format(int(math.fabs(tim[0])), int(math.fabs(tim[1])))).do(day_overview)
schedule.every().day.at("00:00").do(recent_changes.clear_cache)
while 1:
time.sleep(1.0)
schedule.run_pending()
#if (recent_changes.day != ):
#logging.info("A brand new day! Printing the summary and clearing the cache")
##recent_changes.clear_cache()
#recent_changes.day = datetime.datetime.now().day