dongwei2610 2018-05-31 00:31
浏览 582
已采纳

空中刹车抛出错误“ pybrake-ERROR-strconv.ParseInt:解析为“ None”:语法无效”

I'm trying to use the Airbrake logger in a Django project following the steps described in https://github.com/airbrake/pybrake#django-integration.

I've configured my LOGGING setting like so:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'airbrake': {
            'level': 'ERROR',
            'class': 'pybrake.LoggingHandler',
        }
    },
    'loggers': {
        'lucy_web': {
            'handlers': ['airbrake'],
            'level': 'ERROR',
            'propagate': True,
        }
    }
}

Then, in a particular file in the lucy_web hierarchy called lucy_web/lib/session_recommendation.py, I have the following test function:

import logging

logger = logging.getLogger(__name__)

def log_something():
    logger.error("Logging something...")

However, if I try to call this function from the Django shell, pybrake itself logs an error:

strconv.ParseInt: parsing "None": invalid syntax

Here is the full sequence of commands:

(venv) Kurts-MacBook-Pro-2:lucy-web kurtpeek$ python manage.py shell
Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.3.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from lucy_web.lib.session_recommendation import *

In [2]: log_something()

In [3]: 2018-05-30 17:25:32,201 - pybrake - ERROR - strconv.ParseInt: parsing "None": invalid syntax

It would appear from https://golang.org/pkg/strconv/#ParseInt that strconv.ParseInt is actually a built-in function of the Go language, so I don't understand why pybrake, which is a Python package, is throwing this error, or how to debug it. Can anyone explain this error?

  • 写回答

1条回答 默认 最新

  • dtr84664 2018-05-31 02:22
    关注

    It seems airbrake server itself is written in Go.

    This can be inferred from the following facts:

    • In their "About" page (https://airbrake.io/about) they list one of their members as their "Lead Go developer" and say they've been "using Go since before 1.0". Also in their CTO description they say he likes "hacking his home with Go".

    • You are getting a strconv.ParseInt (Go) error from Python

    • There is a report of getting also a strconv.ParseInt from using a Ruby client to report airbrake errors (https://github.com/airbrake/airbrake/issues/502)

    So explanation for the error would be that the Python client is getting this error from the server when sending the report, and logging this.

    As for how to debug this, I'd say the best way would be to capture the request that the client is sending to the server.

    You can do this for example by modifying the code here to point to your own server instead of airbrake's and log the requests:

    https://github.com/airbrake/pybrake/blob/master/pybrake/notifier.py#L41

    Or capture the HTTP traffic somehow.

    You'll probably see a JSON/XML/HTTP Form Data in which there will be a "None" value attached to a property that should instead be a number, which would then raise this error server-side.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 Matlab打开默认名称带有/的光谱数据
  • ¥50 easyExcel模板 动态单元格合并列
  • ¥15 res.rows如何取值使用
  • ¥15 在odoo17开发环境中,怎么实现库存管理系统,或独立模块设计与AGV小车对接?开发方面应如何设计和开发?请详细解释MES或WMS在与AGV小车对接时需完成的设计和开发
  • ¥15 CSP算法实现EEG特征提取,哪一步错了?
  • ¥15 游戏盾如何溯源服务器真实ip?需要30个字。后面的字是凑数的
  • ¥15 vue3前端取消收藏的不会引用collectId
  • ¥15 delphi7 HMAC_SHA256方式加密
  • ¥15 关于#qt#的问题:我想实现qcustomplot完成坐标轴
  • ¥15 下列c语言代码为何输出了多余的空格