37
37
BasePlugin ,
38
38
BaseSyncStopPlugin ,
39
39
PluginContext ,
40
+ TrinityBootInfo ,
40
41
)
41
42
42
43
@@ -58,9 +59,7 @@ def is_responsible_for_plugin(self, plugin: BasePlugin) -> bool:
58
59
@abstractmethod
59
60
def create_plugin_context (self ,
60
61
plugin : BasePlugin ,
61
- args : Namespace ,
62
- trinity_config : TrinityConfig ,
63
- boot_kwargs : Dict [str , Any ]) -> PluginContext :
62
+ boot_info : TrinityBootInfo ) -> PluginContext :
64
63
"""
65
64
Create the ``PluginContext`` for a given plugin.
66
65
"""
@@ -78,19 +77,14 @@ def is_responsible_for_plugin(self, plugin: BasePlugin) -> bool:
78
77
79
78
def create_plugin_context (self ,
80
79
plugin : BasePlugin ,
81
- args : Namespace ,
82
- trinity_config : TrinityConfig ,
83
- boot_kwargs : Dict [str , Any ]) -> PluginContext :
80
+ boot_info : TrinityBootInfo ) -> PluginContext :
84
81
85
82
if isinstance (plugin , BaseIsolatedPlugin ):
86
83
# Isolated plugins get an entirely new endpoint to be passed into that new process
87
- context = PluginContext (
88
- self .event_bus .create_endpoint (plugin .name )
84
+ return PluginContext (
85
+ self .event_bus .create_endpoint (plugin .name ),
86
+ boot_info ,
89
87
)
90
- context .args = args
91
- context .trinity_config = trinity_config
92
- context .boot_kwargs = boot_kwargs
93
- return context
94
88
95
89
# A plugin that overtakes the main process never gets far enough to even get a context.
96
90
# For now it should be safe to just return `None`. Maybe reconsider in the future.
@@ -107,16 +101,10 @@ def is_responsible_for_plugin(self, plugin: BasePlugin) -> bool:
107
101
108
102
def create_plugin_context (self ,
109
103
plugin : BasePlugin ,
110
- args : Namespace ,
111
- trinity_config : TrinityConfig ,
112
- boot_kwargs : Dict [str , Any ]) -> PluginContext :
104
+ boot_info : TrinityBootInfo ) -> PluginContext :
113
105
114
106
# Plugins that run in a shared process all share the endpoint of the plugin manager
115
- context = PluginContext (self .endpoint )
116
- context .args = args
117
- context .trinity_config = trinity_config
118
- context .boot_kwargs = boot_kwargs
119
- return context
107
+ return PluginContext (self .endpoint , boot_info )
120
108
121
109
122
110
class PluginManager :
@@ -173,7 +161,10 @@ def prepare(self,
173
161
if not self ._scope .is_responsible_for_plugin (plugin ):
174
162
continue
175
163
176
- context = self ._scope .create_plugin_context (plugin , args , trinity_config , boot_kwargs )
164
+ context = self ._scope .create_plugin_context (
165
+ plugin ,
166
+ TrinityBootInfo (args , trinity_config , boot_kwargs )
167
+ )
177
168
plugin .set_context (context )
178
169
plugin .ready ()
179
170
0 commit comments