读取参数,每X秒刷新共享内存
def batch_job_004():
if_batch_start = utility.get_myibs_ini(“batch”, “batch_job_004_start”)
batch_start_date = utility.get_myibs_ini(“batch”, “batch_job_004_start_date”)
batch_start_time = utility.get_myibs_ini(“batch”, “batch_job_004_start_time”)
batch_job_internal_time = utility.get_myibs_ini(“batch”, “batch_job_004_internal_time”)
batch_job_started = utility.get_myibs_ini(“batch”, “batch_job_004_status”)
###########################
# scheduled job start here
###########################
conf = configparser.ConfigParser()
logger.info("Loading configuration...")
conf.read(myibs_ini)
rtn_str = None
import mmap
import contextlib
utility.set_myibs_ini("batch", "batch_job_004_status", "STARTED")
with contextlib.closing(mmap.mmap(-1, 1024*1024, tagname="myibs.ini", access=mmap.ACCESS_WRITE)) as m:
sections = conf.sections()
dict_myibs_ini = {}
dict_sections = {}
for section in sections:
items = conf.items(section)
dict_items = {}
for item in items:
in_parm_tagname = "myibs.ini" + ":" + section + ":" + item[0] + "=" + item[1]
logger.info(in_parm_tagname)
print(in_parm_tagname)
dict_items[item[0]] = item[1]
#print(dict_items)
dict_sections[section] = dict_items
#print(dict_sections)
import json
obj_json = json.dumps(dict_sections)
print("dict->json", obj_json)
try:
m.seek(0)
m.write(str(obj_json).encode())
m.flush()
rtn_str = "000000"
except Exception as e:
rtn_code = None
logger.error(e)
print(e)
logger.info("Configuration loaded.")
#time.sleep(100000)
print(obj_json)
return rtn_str