@Maxwell012

WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None))?

Код:
for i in range(thread - 1):
        if pool.size == 0:
            break
        connection_for_thread = pool.get_connection()
        threading.Thread(target=main, args=(data, connection_for_thread, )).start()

Работал с библиотекой pymysql, так как появилась потребность в потоках перешел на pymysqlpool. Перед созданием каждого нового потока я создаю новое соединение с бд, в конце потока я закрываю новое созданное соединение, после завершение выполнение кода потоком появляется ошибка соединения:
09-29 11:38:29  WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000002CF7B5F5E70>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it')': /session/82c173771b8ca9489c22bf1c5462659f/url
09-29 11:38:33  WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000002CF7B5F7910>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it')': /session/82c173771b8ca9489c22bf1c5462659f/url
09-29 11:38:37  WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000002CF7B5F6290>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it')': /session/82c173771b8ca9489c22bf1c5462659f/url
Exception in thread Thread-1 (main):
Traceback (most recent call last):
  File "D:\Program files\Python\lib\site-packages\urllib3\connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "D:\Program files\Python\lib\site-packages\urllib3\util\connection.py", line 95, in create_connection
    raise err
  File "D:\Program files\Python\lib\site-packages\urllib3\util\connection.py", line 85, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Program files\Python\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "D:\Program files\Python\lib\site-packages\urllib3\connectionpool.py", line 398, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "D:\Program files\Python\lib\site-packages\urllib3\connection.py", line 239, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "D:\Program files\Python\lib\http\client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "D:\Program files\Python\lib\http\client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "D:\Program files\Python\lib\http\client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "D:\Program files\Python\lib\http\client.py", line 1037, in _send_output
    self.send(msg)
  File "D:\Program files\Python\lib\http\client.py", line 975, in send
    self.connect()
  File "D:\Program files\Python\lib\site-packages\urllib3\connection.py", line 205, in connect
    conn = self._new_conn()
  File "D:\Program files\Python\lib\site-packages\urllib3\connection.py", line 186, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x000002CF7B5F5B10>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Program files\Python\lib\threading.py", line 1009, in _bootstrap_inner
    self.run()
  File "D:\Program files\Python\lib\threading.py", line 946, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\Davud\Desktop\Бот\bot_for_history\solving_the_test\main.py", line 30, in main
    browser.get(data['link'])
  File "D:\Program files\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 442, in get
    self.execute(Command.GET, {'url': url})
  File "D:\Program files\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 428, in execute
    response = self.command_executor.execute(driver_command, params)
  File "D:\Program files\Python\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 347, in execute
    return self._request(command_info[0], url, body=data)
  File "D:\Program files\Python\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 369, in _request
    response = self._conn.request(method, url, body=body, headers=headers)
  File "D:\Program files\Python\lib\site-packages\urllib3\request.py", line 78, in request
    return self.request_encode_body(
  File "D:\Program files\Python\lib\site-packages\urllib3\request.py", line 170, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "D:\Program files\Python\lib\site-packages\urllib3\poolmanager.py", line 376, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "D:\Program files\Python\lib\site-packages\urllib3\connectionpool.py", line 813, in urlopen
    return self.urlopen(
  File "D:\Program files\Python\lib\site-packages\urllib3\connectionpool.py", line 813, in urlopen
    return self.urlopen(
  File "D:\Program files\Python\lib\site-packages\urllib3\connectionpool.py", line 813, in urlopen
    return self.urlopen(
  File "D:\Program files\Python\lib\site-packages\urllib3\connectionpool.py", line 785, in urlopen
    retries = retries.increment(
  File "D:\Program files\Python\lib\site-packages\urllib3\util\retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=50221): Max retries exceeded with url: /session/82c173771b8ca9489c22bf1c5462659f/url (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000002CF7B5F5B10>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))
  • Вопрос задан
  • 522 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы