I have a request_processor
that processes web requests coming to my python webserver. However, this request_processor
needs to be updated every x hours. I am using schedule
library in python for the same. I want to make sure I am not leaving any holes that compromises thread safety. Please review the following approach that I am doing now which is completely without any locks.
request_processor: IRequestProcessor
def invoke(req):
""" Entry point for web requests"""
response = request_processor.process(req)
...
def init_processor():
_request_processor = ... #S Setup request_processor
global request_processor
request_processor = _request_processor
def schedule_reload():
schedule_model_reload = ContinuousScheduler()
schedule_model_reload.every(SCHEDULE_MINS).minutes.do(init_processor)
halt_schedule_flag = schedule_model_reload.run_continuously()
def server_startup():
init_processor()
schedule_reload()
Please review for thread safety issues in the above code. I am newbie to python programming. Thanks in advance.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…