获取系统环境变量: ACE_OS::getenv

本文提供了一个使用ACE库获取系统环境变量的C++示例代码。通过调用ACE_OS::getenv函数,可以读取特定的环境变量如ACE_ROOT,并在控制台输出其值。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

(1)获取系统环境变量: ACE_OS::getenv

#ifdef _DEBUG
#pragma comment (lib,"ACEd.lib")
#else
#pragma comment (lib,"ACE.lib")
#endif

#include "ace/OS.h"
#include "ace/Log_Msg.h"

int ACE_TMAIN(int argc, ACE_TCHAR** argv)
{
    char * env = 0;
    env = ACE_OS::getenv("ACE_ROOT");
    ACE_DEBUG((LM_DEBUG,"$(ACE_ROOT)=[%s]\n",env));

    return 0;
}

这里写图片描述
这里写图片描述

while True: if IS_OPEN: logging.info("-------------------start------------------------------") start_time1 = time.time() try: # 使用 with 语句管理数据库连接和游标 with cx_Oracle.connect(user='acme', password='acme', dsn=dsn) as connection: with connection.cursor() as cursor: logging.info("SQL查询5个状态为0的lot任务---开始") # TODO 需要改逻辑,如何查5个才能不循环执行当前没有wat的5个 sql_query = """ SELECT DISTINCT DRB_ID FROM ( SELECT DISTINCT DRB_ID, LOT_ID, ROW_NUMBER() OVER (ORDER BY CREATE_TIME ASC) AS RN FROM DRB_INFO_CONFIG WHERE STATUS = 0 ) DRB_CNT WHERE RN <= 5 """ cursor.execute(sql_query) lotresults = cursor.fetchall() logging.info(f"{lotresults}") logging.info("SQL查询5个状态为0的lot任务---结束") except Exception as e: logging.info("查询5个lot并更新状态,数据库操作异常:%s", e) time.sleep(1800) continue with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor: # 提交所有任务 future_to_lot = { executor.submit(execute_query, test.sql_query, {"DRB_ID": lot_item[0]}): lot_item for lot_item in lotresults } # 处理任务状态(仅关注失败情况) for future in concurrent.futures.as_completed(future_to_lot): lot_item = future_to_lot[future] try: # 显式获取结果以触发可能的异常 future.result() # 结果不保存,仅用于异常检查 except Exception as e: logging.info("任务 %s 失败:%s", lot_item, e) end_time1 = time.time() run_time = end_time1 - start_time1 logging.info("代码运行时间为: %s 秒", run_time) else: with cx_Oracle.connect(user='acme', password='acme', dsn=dsn) as connection: with connection.cursor() as cursor: sql_query = """ update DRB_INFO_CONFIG set status = :1, REPORT_STATUS = :2, ACE_LAST_UPDATE_TIME = SYSDATE where REGEXP_LIKE(LOT_ID, '^[BC]0') and status='0' """ cursor.execute(sql_query, (1, 9)) logging.info("fail开关打开") connection.commit() 为这段代码建立定时任务
03-23
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

C++程序员Carea

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值