J-Lindvig / Bibliotek_dk

Custom integration for Home Assistant, scraping loaner status from public libraries in Denmark
GNU General Public License v3.0
9 stars 5 forks source link

Unhandled http error when fetching data #2

Closed larsalthof closed 8 months ago

larsalthof commented 1 year ago

image

JanHG commented 1 year ago

Jeg har en tilsvarende fejl:

2023-04-18 23:45:55.804 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/bibliotek_dk/library_api.py", line 125, in _fetchPage
    r.raise_for_status()
  File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 504 Server Error: Gateway Time-out for url: https://ereolen.dk/adgangsplatformen/callback?code=ec1cc2e9b6bde8217b254ab32efbf2692b936d20&state=86d94a6300dc9bc4560ee725574d8ebc

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 226, in async_refresh
    await self._async_refresh(log_failures=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 250, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 206, in _async_update_data
    return await self.update_method()
  File "/config/custom_components/bibliotek_dk/sensor.py", line 58, in async_update_data
    await hass.async_add_executor_job(myLibrary.update)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/bibliotek_dk/library_api.py", line 97, in update
    loginResult, soup = self.login_eLib()
  File "/config/custom_components/bibliotek_dk/library_api.py", line 372, in login_eLib
    soup = self._fetchPage(
  File "/config/custom_components/bibliotek_dk/library_api.py", line 128, in _fetchPage
    raise SystemExit(err) from err
SystemExit: 504 Server Error: Gateway Time-out for url: https://ereolen.dk/adgangsplatformen/callback?code=ec1cc2e9b6bde8217b254ab32efbf2692b936d20&state=86d94a6300dc9bc4560ee725574d8ebc

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/storage.py", line 260, in _async_callback_delayed_write
    await self._async_handle_write_data()
  File "/usr/src/homeassistant/homeassistant/helpers/storage.py", line 285, in _async_handle_write_data
    await self._async_write_data(self.path, data)
  File "/usr/src/homeassistant/homeassistant/helpers/storage.py", line 290, in _async_write_data
    await self.hass.async_add_executor_job(self._write_data, self.path, data)
  File "/usr/src/homeassistant/homeassistant/core.py", line 555, in async_add_executor_job
    task = self.loop.run_in_executor(None, target, *args)
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 814, in run_in_executor
    self._check_default_executor()
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 519, in _check_default_executor
    raise RuntimeError('Executor shutdown has been called')
RuntimeError: Executor shutdown has been called
larsalthof commented 9 months ago

I believe this is fixed by #7