Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix community component shutdown leaving stuff behind #6338

Merged
merged 1 commit into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from ipv8.peerdiscovery.discovery import RandomWalk

from tribler_common.simpledefs import STATEDIR_DB_DIR

from tribler_core.components.interfaces.bandwidth_accounting import BandwidthAccountingComponent
from tribler_core.components.interfaces.ipv8 import Ipv8Component
from tribler_core.components.interfaces.reporter import ReporterComponent
Expand All @@ -23,7 +24,7 @@ async def run(self):
config = self.session.config

ipv8_component = await self.use(Ipv8Component)
ipv8 = ipv8_component.ipv8
ipv8 = self._ipv8 = ipv8_component.ipv8
peer = ipv8_component.peer
rest_manager = self.rest_manager = (await self.use(RESTComponent)).rest_manager

Expand All @@ -50,4 +51,4 @@ async def run(self):
async def shutdown(self):
self.rest_manager.get_endpoint('trustview').bandwidth_db = None
self.rest_manager.get_endpoint('bandwidth').bandwidth_community = None
await self.community.unload()
await self._ipv8.unload_overlay(self.community)
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async def run(self):
notifier = self.session.notifier

ipv8_component = await self.use(Ipv8Component)
ipv8 = ipv8_component.ipv8
ipv8 = self._ipv8 = ipv8_component.ipv8
peer = ipv8_component.peer
rest_manager = self.rest_manager = (await self.use(RESTComponent)).rest_manager
metadata_store = (await self.use(MetadataStoreComponent)).mds
Expand Down Expand Up @@ -60,4 +60,4 @@ async def shutdown(self):
self.rest_manager.get_endpoint('collections').gigachannel_community = None
await self.release(RESTComponent)

await self.community.unload()
await self._ipv8.unload_overlay(self.community)
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ async def shutdown(self):
self.rest_manager.get_endpoint('statistics').ipv8 = None
await self.release(RESTComponent)

for overlay in (self.dht_discovery_community, self.peer_discovery_community):
if overlay:
await self.ipv8.unload_overlay(overlay)

await self.unused.wait()
self.session.notifier.notify_shutdown_state("Shutting down IPv8...")
await self.task_manager.shutdown_task_manager()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async def run(self):

config = self.session.config
ipv8_component = await self.use(Ipv8Component)
ipv8 = ipv8_component.ipv8
ipv8 = self._ipv8 = ipv8_component.ipv8
peer = ipv8_component.peer
metadata_store = (await self.use(MetadataStoreComponent)).mds

Expand All @@ -39,4 +39,4 @@ async def run(self):
ipv8.overlays.append(community)

async def shutdown(self):
await self.community.unload()
await self._ipv8.unload_overlay(self.community)
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async def run(self):

config = self.session.config
ipv8_component = await self.use(Ipv8Component)
ipv8 = ipv8_component.ipv8
ipv8 = self._ipv8 = ipv8_component.ipv8
peer = ipv8_component.peer
dht_discovery_community = ipv8_component.dht_discovery_community

Expand Down Expand Up @@ -80,4 +80,4 @@ async def run(self):
debug_endpoint.tunnel_community = community

async def shutdown(self):
await self.community.unload()
await self._ipv8.unload_overlay(self.community)
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from unittest.mock import Mock

from ipv8_service import IPv8

from tribler_core.components.base import Component, testcomponent
from tribler_core.config.tribler_config import TriblerConfig
from tribler_core.modules.bandwidth_accounting.community import BandwidthAccountingCommunity
Expand All @@ -8,6 +10,7 @@
class BandwidthAccountingComponent(Component):
community: BandwidthAccountingCommunity
enable_in_gui_test_mode = True
_ipv8: IPv8

@classmethod
def should_be_enabled(cls, config: TriblerConfig):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from unittest.mock import Mock

from ipv8_service import IPv8

from tribler_core.components.base import Component, testcomponent
from tribler_core.config.tribler_config import TriblerConfig
from tribler_core.modules.metadata_store.community.gigachannel_community import GigaChannelCommunity
Expand All @@ -9,6 +11,7 @@ class GigaChannelComponent(Component):
enable_in_gui_test_mode = True

community: GigaChannelCommunity
_ipv8: IPv8

@classmethod
def should_be_enabled(cls, config: TriblerConfig):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from unittest.mock import Mock

from ipv8_service import IPv8

from tribler_core.components.base import Component, testcomponent
from tribler_core.config.tribler_config import TriblerConfig
from tribler_core.modules.popularity.community import PopularityCommunity
Expand All @@ -9,6 +11,7 @@ class PopularityComponent(Component):
enable_in_gui_test_mode = True

community: PopularityCommunity
_ipv8: IPv8

@classmethod
def should_be_enabled(cls, config: TriblerConfig):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
from unittest.mock import Mock

from ipv8_service import IPv8

from tribler_core.components.base import Component, testcomponent
from tribler_core.config.tribler_config import TriblerConfig
from tribler_core.modules.tunnel.community.community import TriblerTunnelCommunity


class TunnelsComponent(Component):
community: TriblerTunnelCommunity
_ipv8: IPv8

@classmethod
def should_be_enabled(cls, config: TriblerConfig):
Expand Down