Skip to content

Commit 62971cd

Browse files
committed
Set PluginContext in scope, not PluginManager
1 parent efbcb64 commit 62971cd

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

trinity/extensibility/plugin_manager.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def is_responsible_for_plugin(self, plugin: BasePlugin) -> bool:
5959
@abstractmethod
6060
def create_plugin_context(self,
6161
plugin: BasePlugin,
62-
boot_info: TrinityBootInfo) -> PluginContext:
62+
boot_info: TrinityBootInfo) -> None:
6363
"""
6464
Create the ``PluginContext`` for a given plugin.
6565
"""
@@ -77,18 +77,14 @@ def is_responsible_for_plugin(self, plugin: BasePlugin) -> bool:
7777

7878
def create_plugin_context(self,
7979
plugin: BasePlugin,
80-
boot_info: TrinityBootInfo) -> PluginContext:
80+
boot_info: TrinityBootInfo) -> None:
8181

8282
if isinstance(plugin, BaseIsolatedPlugin):
8383
# Isolated plugins get an entirely new endpoint to be passed into that new process
84-
return PluginContext(
84+
plugin.set_context(PluginContext(
8585
self.event_bus.create_endpoint(plugin.name),
8686
boot_info,
87-
)
88-
89-
# A plugin that overtakes the main process never gets far enough to even get a context.
90-
# For now it should be safe to just return `None`. Maybe reconsider in the future.
91-
return None
87+
))
9288

9389

9490
class SharedProcessScope(BaseManagerProcessScope):
@@ -101,10 +97,10 @@ def is_responsible_for_plugin(self, plugin: BasePlugin) -> bool:
10197

10298
def create_plugin_context(self,
10399
plugin: BasePlugin,
104-
boot_info: TrinityBootInfo) -> PluginContext:
100+
boot_info: TrinityBootInfo) -> None:
105101

106102
# Plugins that run in a shared process all share the endpoint of the plugin manager
107-
return PluginContext(self.endpoint, boot_info)
103+
plugin.set_context(PluginContext(self.endpoint, boot_info))
108104

109105

110106
class PluginManager:
@@ -161,11 +157,10 @@ def prepare(self,
161157
if not self._scope.is_responsible_for_plugin(plugin):
162158
continue
163159

164-
context = self._scope.create_plugin_context(
160+
self._scope.create_plugin_context(
165161
plugin,
166162
TrinityBootInfo(args, trinity_config, boot_kwargs)
167163
)
168-
plugin.set_context(context)
169164
plugin.ready()
170165

171166
def shutdown_blocking(self) -> None:

0 commit comments

Comments
 (0)