1024programmer Java Django source code analysis

Django source code analysis

Timer scene

from threading import Timer

def run(self): while not self.finished.is_set(): self.function(*self.args, **self.kwargs) self.finished.wait(self.interval) class Command(BaseCommand): def handle(self, *args, **options): try: if get_execute_flag(): init_conn() timer_list = [ # Market homepage data cache CustomTimer(1.0, timed_refresh_market_home_page_data), # Invitation ranking event switch cache CustomTimer(1.0, timed_refresh_invite_leaderboard_activity_switch_data), ] # Start caching for t in timer_list: t.start() while True: if not get_execute_flag(): # Cancel scheduled caching for t in timer_list: t.cancel() break time.sleep(5) except: write_error_log(\'main\') finally: time.sleep(5)

timer source code

First analyze the wait source code

When wait is used, lock’s wait

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/772405

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us


Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top