Skip to content

Commit

Permalink
Merge pull request #7196 from drew2a/fix/7195
Browse files Browse the repository at this point in the history
Add `EventsEndpoint.shutdown()`
  • Loading branch information
drew2a authored Nov 21, 2022
2 parents 4dd1018 + 3dc29e1 commit 4ea5f08
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/tribler/core/components/restapi/rest/events_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ def on_circuit_removed(self, circuit: Circuit, additional_info: str):
async def on_shutdown(self, _):
await self.shutdown_task_manager()

async def shutdown(self):
await self.shutdown_task_manager()

def setup_routes(self):
self.app.add_routes([web.get('', self.get_events)])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
messages_to_wait_for = set()


# pylint: disable=redefined-outer-name

@pytest.fixture(name='api_port')
def fixture_api_port(free_port):
return free_port
Expand All @@ -29,9 +31,12 @@ def fixture_notifier(event_loop):
return Notifier(loop=event_loop)


@pytest.fixture(name='endpoint')
def fixture_endpoint(notifier):
return EventsEndpoint(notifier)
@pytest.fixture
async def endpoint(notifier):
events_endpoint = EventsEndpoint(notifier)
yield events_endpoint

await events_endpoint.shutdown()


@pytest.fixture(name='reported_error')
Expand Down
3 changes: 3 additions & 0 deletions src/tribler/core/components/restapi/restapi_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ def report_callback(reported_error: ReportedError):
async def shutdown(self):
await super().shutdown()

if self._events_endpoint:
await self._events_endpoint.shutdown()

if self._core_exception_handler:
self._core_exception_handler.report_callback = None

Expand Down

0 comments on commit 4ea5f08

Please sign in to comment.