Задать вопрос
@aqau123

Почему ошибка не обрабатывается?

try:
            wdriver.get(link)
except Exception as e:
            eCounter.increaseCounter()
            errorOutput(wdriver, output, e)
            continue

вот такой код, в этом месте вылетает ошибка
Message:

[17:48:35]
Done gathering items links.
Getting items:   0%|                                                     | 0/906 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "main.py", line 84, in getInfoItem
    wdriver.get(link)
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 323, in get
    self.execute(Command.GET, {'url': url})
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 309, in execute
    response = self.command_executor.execute(driver_command, params)
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 460, in execute
    return self._request(command_info[0], url, body=data)
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 483, in _request
    self._conn.request(method, parsed_url.path, body, headers)
  File "/usr/local/lib/python3.7/http/client.py", line 1281, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/lib/python3.7/http/client.py", line 1327, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.7/http/client.py", line 1276, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.7/http/client.py", line 1075, in _send_output
    self.send(chunk)
  File "/usr/local/lib/python3.7/http/client.py", line 997, in send
    self.sock.sendall(data)
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 247, in <module>
    [perform(output=output, mainLink=citieLink, errorCounter=errorCounter) for citieLink in citiesLink]
  File "main.py", line 247, in <listcomp>
    [perform(output=output, mainLink=citieLink, errorCounter=errorCounter) for citieLink in citiesLink]
  File "main.py", line 236, in perform
    getInfoItem(driver, itemsLinks, output, errorCounter)
  File "main.py", line 87, in getInfoItem
    errorOutput(wdriver, output, e)
  File "main.py", line 186, in errorOutput
    wdriver.current_url,
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 577, in current_url
    return self.execute(Command.GET_CURRENT_URL)['value']
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 309, in execute
    response = self.command_executor.execute(driver_command, params)
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 460, in execute
    return self._request(command_info[0], url, body=data)
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 483, in _request
    self._conn.request(method, parsed_url.path, body, headers)
  File "/usr/local/lib/python3.7/http/client.py", line 1281, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/lib/python3.7/http/client.py", line 1327, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.7/http/client.py", line 1276, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.7/http/client.py", line 1036, in _send_output
    self.send(msg)
  File "/usr/local/lib/python3.7/http/client.py", line 976, in send
    self.connect()
  File "/usr/local/lib/python3.7/http/client.py", line 948, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "/usr/local/lib/python3.7/socket.py", line 728, in create_connection
    raise err
  File "/usr/local/lib/python3.7/socket.py", line 716, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

Почему она крашит скрипт а не обрабатывается?
  • Вопрос задан
  • 321 просмотр
Подписаться 1 Простой Комментировать
Решения вопроса 1
@Andy_U
Так у вас ошибка снова генерируется уже в errorOutput... Учитесь читать Traceback...
Ответ написан
Пригласить эксперта
Ответы на вопрос 1
bravebug
@bravebug
During handling of the above exception, another exception occurred

Во время обработки вышеупомянутого исключения произошло другое исключение

Т.е. код в блоке "except" сам порождает исключение.
Ответ написан
Комментировать
Ваш ответ на вопрос

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

Похожие вопросы
22 дек. 2024, в 20:40
10000 руб./за проект
22 дек. 2024, в 20:34
3000 руб./за проект
22 дек. 2024, в 20:12
10000 руб./за проект