[F] Fix mutating while traversing warning
This commit is contained in:
+5
-3
@@ -32,7 +32,7 @@ class Scheduler:
|
|||||||
self.updater = updater
|
self.updater = updater
|
||||||
|
|
||||||
# Start job
|
# Start job
|
||||||
self.job = self.updater.job_queue.run_repeating(self.update, interval=5, first=0)
|
self.job = self.updater.job_queue.run_repeating(self.update, interval=20, first=0)
|
||||||
|
|
||||||
# Update tasks
|
# Update tasks
|
||||||
def update(self, context: CallbackContext):
|
def update(self, context: CallbackContext):
|
||||||
@@ -41,6 +41,8 @@ class Scheduler:
|
|||||||
|
|
||||||
# Function to update a single task
|
# Function to update a single task
|
||||||
def updateTask(cache: CacheEntry):
|
def updateTask(cache: CacheEntry):
|
||||||
|
print("DEBUG: Sending request - %s" % cache.name, nowText)
|
||||||
|
|
||||||
request = self.database.reqs[cache.user][cache.name]
|
request = self.database.reqs[cache.user][cache.name]
|
||||||
if now - cache.time < request.get('interval', 120):
|
if now - cache.time < request.get('interval', 120):
|
||||||
return
|
return
|
||||||
@@ -70,8 +72,8 @@ class Scheduler:
|
|||||||
context.bot.send_document(int(user), doc, fileName, caption, parse_mode='markdown')
|
context.bot.send_document(int(user), doc, fileName, caption, parse_mode='markdown')
|
||||||
|
|
||||||
# Update all tasks
|
# Update all tasks
|
||||||
for user in self.storage:
|
for user in self.storage.keys():
|
||||||
for name in self.storage[user]:
|
for name in self.storage[user].keys():
|
||||||
updateTask(self.storage[user][name])
|
updateTask(self.storage[user][name])
|
||||||
|
|
||||||
# Start a task
|
# Start a task
|
||||||
|
|||||||
Reference in New Issue
Block a user