Remove some print command and correct commented NOTE

This commit is contained in:
Schimon Jehudah 2023-11-02 12:05:43 +00:00
parent d712eaea31
commit af93a3781c

View file

@ -98,9 +98,8 @@ class Slixfeed(slixmpp.ClientXMPP):
message = " ".join(msg["body"].split()) message = " ".join(msg["body"].split())
message = message.lower() message = message.lower()
print(print_time(), "COMMAND ACCOUNT") print(print_time(), "ACCOUNT: " + str(msg["from"]))
print("COMMAND:", message) print(print_time(), "COMMAND:", message)
print("ACCOUNT: " + str(msg["from"]))
if message.startswith("help"): if message.startswith("help"):
action = print_help() action = print_help()
@ -150,9 +149,7 @@ class Slixfeed(slixmpp.ClientXMPP):
elif message.startswith("stop"): elif message.startswith("stop"):
# action = "Updates are disabled." # action = "Updates are disabled."
try: try:
print(print_time(), "task_manager[jid]") # task_manager[jid]["check"].cancel()
print(task_manager[jid])
task_manager[jid]["check"].cancel()
# task_manager[jid]["status"].cancel() # task_manager[jid]["status"].cancel()
task_manager[jid]["interval"].cancel() task_manager[jid]["interval"].cancel()
key = "enabled" key = "enabled"
@ -160,12 +157,13 @@ class Slixfeed(slixmpp.ClientXMPP):
action = await initdb(jid, sqlitehandler.set_settings_value, [key, val]) action = await initdb(jid, sqlitehandler.set_settings_value, [key, val])
except: except:
action = "Updates are already disabled." action = "Updates are already disabled."
print("Updates are already disabled. Nothing to do.") # print("Updates are already disabled. Nothing to do.")
# await self.send_status(jid) # await self.send_status(jid)
await self.task_jid(jid)
else: else:
action = "Unknown command. Press \"help\" for list of commands" action = "Unknown command. Press \"help\" for list of commands"
# NOTE Message won't be sent if status is send before it # NOTE Message won't be sent if status is send before it
# await self.send_status(jid) # Or it is because we cancel task send_status
if action: msg.reply(action).send() if action: msg.reply(action).send()
@ -195,20 +193,11 @@ class Slixfeed(slixmpp.ClientXMPP):
# jid_tasker[jid] = asyncio.create_task(self.task_jid(jid)) # jid_tasker[jid] = asyncio.create_task(self.task_jid(jid))
# await jid_tasker[jid] # await jid_tasker[jid]
async with asyncio.TaskGroup() as tg: async with asyncio.TaskGroup() as tg:
print("main task")
print(print_time(), "repr(tg)")
print(repr(tg)) # <TaskGroup entered>
for file in files: for file in files:
if file.endswith(".db") and not file.endswith(".db-jour.db"): if file.endswith(".db") and not file.endswith(".db-jour.db"):
jid = file[:-3] jid = file[:-3]
tg.create_task(self.task_jid(jid)) tg.create_task(self.task_jid(jid))
# task_manager.update({jid: tg}) # task_manager.update({jid: tg})
# print(task_manager) # {}
print(print_time(), "repr(tg) id(tg)")
print(jid, repr(tg)) # sch@pimux.de <TaskGroup tasks=1 entered>
print(jid, id(tg)) # sch@pimux.de 139879835500624
# <xmpphandler.Slixfeed object at 0x7f24922124d0> <TaskGroup tasks=2 entered>
# <xmpphandler.Slixfeed object at 0x7f24922124d0> 139879835500624
async def task_jid(self, jid): async def task_jid(self, jid):
@ -225,10 +214,6 @@ class Slixfeed(slixmpp.ClientXMPP):
) )
print(print_time(), "enabled", enabled, jid) print(print_time(), "enabled", enabled, jid)
if enabled: if enabled:
print("sub task")
print(print_time(), "repr(self) id(self)")
print(repr(self))
print(id(self))
task_manager[jid] = {} task_manager[jid] = {}
task_manager[jid]["check"] = asyncio.create_task(check_updates(jid)) task_manager[jid]["check"] = asyncio.create_task(check_updates(jid))
task_manager[jid]["status"] = asyncio.create_task(self.send_status(jid)) task_manager[jid]["status"] = asyncio.create_task(self.send_status(jid))
@ -236,12 +221,6 @@ class Slixfeed(slixmpp.ClientXMPP):
await task_manager[jid]["check"] await task_manager[jid]["check"]
await task_manager[jid]["status"] await task_manager[jid]["status"]
await task_manager[jid]["interval"] await task_manager[jid]["interval"]
print(print_time(), "task_manager[jid].items()")
print(task_manager[jid].items())
print(print_time(), "task_manager[jid]")
print(task_manager[jid])
print(print_time(), "task_manager")
print(task_manager)
else: else:
await self.send_status(jid) await self.send_status(jid)
@ -339,13 +318,6 @@ class Slixfeed(slixmpp.ClientXMPP):
""" """
if jid in task_manager: if jid in task_manager:
task_manager[jid][key].cancel() task_manager[jid][key].cancel()
loop = asyncio.get_event_loop()
print(print_time(), "loop")
print(loop)
print(print_time(), "loop.time()")
print(print_time(), loop.time())
print(print_time(), "self.loop.time()")
print(print_time(), self.loop.time())
task_manager[jid][key] = loop.call_at( task_manager[jid][key] = loop.call_at(
loop.time() + 60 * float(val), loop.time() + 60 * float(val),
loop.create_task, loop.create_task,