# Buggy code
def __init__(
    self,
    influx_server: str,
    influx_user: str,
    influx_password: str,
    influx_database: str,
    host: str,
    port: int,
    protocol: str,
    reporting_frequency: int,
):
    self._influx_server = influx_server
    self._reporting_frequency = reporting_frequency
    self._registry = HostMetricsRegistry(host)
    self._reporter = InfluxReporter(
        registry=self._registry,
        database=influx_database,
        username=influx_user,
        password=influx_password,
        protocol=protocol,
        port=port,
        server=influx_server,
    )


# Traceback (combined_error)
Traceback (most recent call last):
File "/usr/src/app/trinity/trinity/extensibility/trio.py", line 50, in run_process
await self.do_run(event_bus)
File "/usr/src/app/trinity/trinity/components/builtin/metrics/component.py", line 171, in do_run
await managers[0].wait_finished()
File "/usr/local/lib/python3.7/contextlib.py", line 678, in __aexit__
raise exc_details[1]
File "/usr/local/lib/python3.7/contextlib.py", line 661, in __aexit__
cb_suppress = await cb(*exc_details)
File "/usr/local/lib/python3.7/contextlib.py", line 552, in _exit_wrapper
return await cm_exit(cm, exc_type, exc, tb)
File "/usr/local/lib/python3.7/site-packages/async_generator/_util.py", line 53, in __aexit__
await self._agen.athrow(type, value, traceback)
File "/usr/local/lib/python3.7/site-packages/async_service/trio.py", line 411, in background_trio_service
await manager.stop()
File "/usr/local/lib/python3.7/site-packages/trio/_core/_run.py", line 730, in __aexit__
raise combined_error_from_nursery
File "/usr/local/lib/python3.7/site-packages/async_service/trio.py", line 208, in run
for _, exc_value, exc_tb in self._errors
File "/usr/local/lib/python3.7/site-packages/async_service/base.py", line 300, in _run_and_manage_task
await task.run()
File "/usr/local/lib/python3.7/site-packages/async_service/trio.py", line 76, in run
await self._async_fn(*self._async_fn_args)
File "/usr/src/app/trinity/trinity/components/builtin/metrics/service/trio.py", line 10, in continuously_report
self._reporter.report_now()
File "/usr/local/lib/python3.7/site-packages/pyformance/reporters/influx.py", line 88, in report_now
response = urlopen(request)
File "/usr/local/lib/python3.7/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/usr/local/lib/python3.7/urllib/request.py", line 525, in open
response = self._open(req, data)
File "/usr/local/lib/python3.7/urllib/request.py", line 543, in _open
'_open', req)
File "/usr/local/lib/python3.7/urllib/request.py", line 503, in _call_chain
result = func(*args)
File "/usr/local/lib/python3.7/urllib/request.py", line 1345, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "/usr/local/lib/python3.7/urllib/request.py", line 1320, in do_open
r = h.getresponse()
File "/usr/local/lib/python3.7/http/client.py", line 1336, in getresponse
response.begin()
File "/usr/local/lib/python3.7/http/client.py", line 306, in begin
version, status, reason = self._read_status()
File "/usr/local/lib/python3.7/http/client.py", line 275, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

# Fixed code
def __init__(
    self,
    influx_server: str,
    influx_user: str,
    influx_password: str,
    influx_database: str,
    host: str,
    port: int,
    protocol: str,
    reporting_frequency: int,
):
    self._unreported_error: Exception = None
    self._last_time_reported: float = 0.0
    self._influx_server = influx_server
    self._reporting_frequency = reporting_frequency
    self._registry = HostMetricsRegistry(host)
    self._reporter = InfluxReporter(
        registry=self._registry,
        database=influx_database,
        username=influx_user,
        password=influx_password,
        protocol=protocol,
        port=port,
        server=influx_server,
    )