How to Create Python Processor / Automated Task

Step-1: Create on python File ( module)

Step-2:  This is Formate we need to used, add your logic (.....ur logic) and If u want change sleep time to run or Automated Task every seconds/day/hours

 import threading

import time

class ClassProcesses(threading.Thread):

    def __init__(self, **kwargs):

        threading.Thread.__init__(self)

print('thread ID ----- ', threading.current_thread().ident)

self.start()

    def run(self):

        print("RUN Method Started")

while True:

.....ur logic

time.sleep(86400) # For 1 day

        print("sleep time completed")

if '__main__' == __name__:

    ClassProcesses()



Using this Schedule library u can easily run your code atomated


import schedule

class Test_1():


def run():

# schedule.every(2).minutes.do(self.contest_processor)

schedule.every().day.at("00:00").do(excute_method)

while True:

      schedule.run_pending()

      time.sleep(1)


def excute_method()

    pass

Comments

Popular posts from this blog

ERR: error parsing query: found influx, expected SELECT, DELETE, SHOW, CREATE, DROP, EXPLAIN, GRANT, REVOKE, ALTER, SET, KILL at line

How to get Full URL or get absolute url In Django

How To Convert Html File/URL/String Into Image Using Python