Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

代码空转 #382

Open
Jacky0334 opened this issue Feb 25, 2025 · 0 comments
Open

代码空转 #382

Jacky0334 opened this issue Feb 25, 2025 · 0 comments

Comments

@Jacky0334
Copy link

def run_with_args(run_fun, *args):
if len(sys.argv) == 3:
# 区间作业 python xxx.py 2023-03-01 2023-03-21
tmp_year, tmp_month, tmp_day = sys.argv[1].split("-")
start_date = datetime.datetime(int(tmp_year), int(tmp_month), int(tmp_day)).date()
tmp_year, tmp_month, tmp_day = sys.argv[2].split("-")
end_date = datetime.datetime(int(tmp_year), int(tmp_month), int(tmp_day)).date()
run_date = start_date
try:
with concurrent.futures.ThreadPoolExecutor() as executor:
while run_date <= end_date:
if trd.is_trade_date(run_date):
executor.submit(run_fun, run_date, *args)
time.sleep(2)
run_date += datetime.timedelta(days=1)
except Exception as e:
logging.error(f"run_template.run_with_args处理异常:{run_fun}{sys.argv}{e}")

执行:
def main():
runt.run_with_args(save_nph_stock_spot_data)
runt.run_with_args(save_nph_etf_spot_data)
参数:2010-01-01 2025-02-25

那么程序将空转至2025-02-25,非常耗时间

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant