流程结束,退出代码为245

时间:2019-08-31 15:06:11

标签: python

Ubuntu 18.04

Python 3.7.3

Django == 2.2.3

堆栈跟踪:

pydev debugger: process 20074 is connecting

Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
August 31, 2019 - 14:28:33
Django version 2.2.3, using settings 'ads_manager.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Not Found: /]
[31/Aug/2019 14:30:22] "GET /] HTTP/1.1" 404 9405
[31/Aug/2019 14:30:24] "GET / HTTP/1.1" 200 4908
[31/Aug/2019 14:30:24] "GET /static/main.css HTTP/1.1" 304 0
/home/michael/PycharmProjects/ads1/venv/lib/python3.7/site-packages/urllib3/connectionpool.py:851: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
/home/michael/PycharmProjects/ads1/venv/lib/python3.7/site-packages/urllib3/connectionpool.py:851: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
/home/michael/PycharmProjects/ads1/venv/lib/python3.7/site-packages/urllib3/connectionpool.py:851: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
/home/michael/PycharmProjects/ads1/venv/lib/python3.7/site-packages/urllib3/connectionpool.py:851: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
/home/michael/PycharmProjects/ads1/venv/lib/python3.7/site-packages/urllib3/connectionpool.py:851: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
/home/michael/PycharmProjects/ads1/venv/lib/python3.7/site-packages/urllib3/connectionpool.py:851: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
/home/michael/PycharmProjects/ads1/venv/lib/python3.7/site-packages/urllib3/connectionpool.py:851: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
/home/michael/PycharmProjects/ads1/venv/lib/python3.7/site-packages/urllib3/connectionpool.py:851: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
/home/michael/PycharmProjects/ads1/venv/lib/python3.7/site-packages/urllib3/connectionpool.py:851: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
/home/michael/PycharmProjects/ads1/venv/lib/python3.7/site-packages/urllib3/connectionpool.py:851: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
/home/michael/PycharmProjects/ads1/venv/lib/python3.7/site-packages/urllib3/connectionpool.py:851: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
/home/michael/PycharmProjects/ads1/venv/lib/python3.7/site-packages/urllib3/connectionpool.py:851: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
/home/michael/PycharmProjects/ads1/venv/lib/python3.7/site-packages/urllib3/connectionpool.py:851: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
/home/michael/PycharmProjects/ads1/venv/lib/python3.7/site-packages/urllib3/connectionpool.py:851: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
/home/michael/PycharmProjects/ads1/venv/lib/python3.7/site-packages/urllib3/connectionpool.py:851: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
/home/michael/PycharmProjects/ads1/venv/lib/python3.7/site-packages/urllib3/connectionpool.py:851: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)

Process finished with exit code 245

一个循环中有几个http请求。换句话说,此函数被多次调用:

import requests
def execute_request(ad_entity, data, url=None):
    data_bytes = json.dumps(data, ensure_ascii=False).encode("utf-8")

    headers = get_headers()

    URL = url or '{}{}/'.format(API_ADDRESS, ad_entity.value.lower())

    response = requests.post(URL, headers=headers, data=data_bytes,
                             verify=False)

问题似乎与python本身的线程安全有关。 Django似乎没什么用。我试图通过在两次请求之间增加最多2秒的睡眠来解决此问题。据我所知,这并没有帮助。

您能给我一个踢一下吗? 1.该代码是什么意思,以及在何处阅读? 2.这个问题有什么解决办法吗? 3.我可以打开更详细的日志记录还是在某处找到更深入的日志? 4.无论如何,如何定位此问题?

1 个答案:

答案 0 :(得分:0)

由于禁用了HTTPS证书验证,这些警告来自urllib3模块。

负责该操作的部分是verify=False,只需将其删除或替换为verify=True(默认)即可

抑制警告的另一种方法(强烈建议 )是在导入请求之前添加以下内容:

import urllib3
urllib3.disable_warnings()