@@ -59,7 +59,7 @@ def is_responsible_for_plugin(self, plugin: BasePlugin) -> bool:
59
59
@abstractmethod
60
60
def create_plugin_context (self ,
61
61
plugin : BasePlugin ,
62
- boot_info : TrinityBootInfo ) -> PluginContext :
62
+ boot_info : TrinityBootInfo ) -> None :
63
63
"""
64
64
Create the ``PluginContext`` for a given plugin.
65
65
"""
@@ -77,18 +77,14 @@ def is_responsible_for_plugin(self, plugin: BasePlugin) -> bool:
77
77
78
78
def create_plugin_context (self ,
79
79
plugin : BasePlugin ,
80
- boot_info : TrinityBootInfo ) -> PluginContext :
80
+ boot_info : TrinityBootInfo ) -> None :
81
81
82
82
if isinstance (plugin , BaseIsolatedPlugin ):
83
83
# Isolated plugins get an entirely new endpoint to be passed into that new process
84
- return PluginContext (
84
+ plugin . set_context ( PluginContext (
85
85
self .event_bus .create_endpoint (plugin .name ),
86
86
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
+ ))
92
88
93
89
94
90
class SharedProcessScope (BaseManagerProcessScope ):
@@ -101,10 +97,10 @@ def is_responsible_for_plugin(self, plugin: BasePlugin) -> bool:
101
97
102
98
def create_plugin_context (self ,
103
99
plugin : BasePlugin ,
104
- boot_info : TrinityBootInfo ) -> PluginContext :
100
+ boot_info : TrinityBootInfo ) -> None :
105
101
106
102
# 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 ) )
108
104
109
105
110
106
class PluginManager :
@@ -161,11 +157,10 @@ def prepare(self,
161
157
if not self ._scope .is_responsible_for_plugin (plugin ):
162
158
continue
163
159
164
- context = self ._scope .create_plugin_context (
160
+ self ._scope .create_plugin_context (
165
161
plugin ,
166
162
TrinityBootInfo (args , trinity_config , boot_kwargs )
167
163
)
168
- plugin .set_context (context )
169
164
plugin .ready ()
170
165
171
166
def shutdown_blocking (self ) -> None :
0 commit comments