fcfangcc / pyxxl

XXL-JOB的Python执行器实现,可以方便的将Python方法注册到XXL-JOB的调度中心上进行管理
https://fcfangcc.github.io/pyxxl/
GNU General Public License v3.0
60 stars 16 forks source link

使用pyxxl执行任务报错,《TypeError: RunData.__init__() got an unexpected keyword argument 'logDateTim'》 #49

Closed youtwo123 closed 5 months ago

youtwo123 commented 5 months ago

Problem description

使用pyxxl执行任务报错,《TypeError: RunData.init() got an unexpected keyword argument 'logDateTim'》

Steps to reproduce the problem

import time

from pyxxl import ExecutorConfig, PyxxlRunner

# 如果xxl-admin可以直连executor的ip,可以不填写executor_listen_host
config = ExecutorConfig(
    xxl_admin_baseurl="http://test-xjob-admin.baijia.com/api/",
    executor_app_name="xhs-traffic",
    executor_host="10.252.71.58",  # xxl-admin访问executor的地址
    executor_listen_host="0.0.0.0",  # xxl-admin监听时绑定的host
    debug=True,
)

app = PyxxlRunner(config)

@app.register(name="testLytHandler")
def test_task_lyt1():
    # you can get task params with "g"
    print("test-lyt")
    return "成功..."

if __name__ == "__main__":
    app.run_executor()

详细报错

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyxxl/server.py", line 53, in run
    run_data = RunData(**data)
               ^^^^^^^^^^^^^^^
TypeError: RunData.__init__() got an unexpected keyword argument 'logDateTim'

Specifications like the version of the project, operating system, or hardware

youtwo123 commented 5 months ago

site-packages/pyxxl/schema.py RunData里加一行,logDateTim: Optional[int] = None,就可以了

fcfangcc commented 5 months ago

最新版对多出的字段做了兼容,会忽略不需要的字段