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

每次执行完任务之后,都会报空指针异常 #34

Closed dislazy closed 1 year ago

dislazy commented 1 year ago

job方法:

@app.register(name="processData")
async def test_task():
    # 模拟异步操作
    await asyncio.sleep(1)
    return "成功..."

调用结果截图:

image

报错日志详情

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/pyxxl/executor.py", line 228, in _run
    await self.xxl_client.callback(data.logId, start_time, code=200, msg=result)
  File "/usr/local/lib/python3.9/site-packages/pyxxl/xxl_client.py", line 81, in callback
    await self._post("callback", payload)
  File "/usr/local/lib/python3.9/site-packages/pyxxl/xxl_client.py", line 93, in _post
    raise XXLRegisterError(r.msg or "")
pyxxl.error.XXLRegisterError: java.lang.NullPointerException

感谢作者开发该项目,希望能一起帮忙解决

fcfangcc commented 1 year ago

java.lang.NullPointerException这是Java抛出来的异常。

看起来是pyxxl执行完任务,回调xxl-job的时候对方的接口报错了,需要看下xxl-job的日志

dislazy commented 1 year ago

下面的是xxl-job的日志,我们使用的xxl-job的版本是2.20

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:109)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
    at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:747)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1594)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)
14:51:01.027 logback [http-nio-8002-exec-17] ERROR c.x.j.a.c.r.WebExceptionResolver - WebExceptionResolver:{}
fcfangcc commented 1 year ago

你xxl_admin_baseurl参数填的是类似于

http://localhost:8080/xxl-job-admin/api/

尝试改成下面试试 http://localhost:8080/xxl-job-admin/

貌似2.2的接口是不带api的

2.2版本文档

2.4版本文档

dislazy commented 1 year ago

好的,我试试看

dislazy commented 1 year ago

修改了之后,python就不会注册到xxl-job了 很可能是 api在最新版本有改动

2023-10-12 15:19:59.455 [MainThread] [NotInTask] WARNING /usr/local/lib/python3.9/site-packages/pyxxl/main.py(_register_task:68) - Register task is exit.
fcfangcc commented 1 year ago

好吧,我搞个2.2的镜像试试吧

dislazy commented 1 year ago

image 目前看2.2是支持的,不行的话我这边看看能不能升级xxl-job

fcfangcc commented 1 year ago

找到问题了,2.2版本callback接口接受格式为

[{
        "logId":1,              // 本次调度日志ID
        "logDateTim":0,         // 本次调度日志时间
        "executeResult":{
            "code": 200,        // 200 表示任务执行正常,500表示失败
            "msg": null
        }
    }]

之后的版本为

[{
        "logId":1,              // 本次调度日志ID
        "logDateTim":0,         // 本次调度日志时间
        "handleCode":200,       // 200 表示任务执行正常,500表示失败
        "handleMsg": null
        }
    }]

后续我会发布一个新版本兼容一下

fcfangcc commented 1 year ago

安装最新版本 0.3.3 试一下 @dislazy

dislazy commented 1 year ago

好的 我试试

dislazy commented 1 year ago

已经可以了,没有报错日志了,非常感谢