Skip to content

Commit 58e4eaf

Browse files
committed
Make accidentially private methods public
These methods were named so that they appeared private by convention. This convention causes trouble in the documentation where these methods are righfully dropped. Since these methods aren't really private in reality (they need to be overwritten in subclasses), they were renamed, migrating their naming from `_*` to `do_*`.
1 parent ee384c7 commit 58e4eaf

File tree

6 files changed

+21
-21
lines changed

6 files changed

+21
-21
lines changed

trinity/extensibility/plugin.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,18 @@ def configure_parser(self, arg_parser: ArgumentParser, subparser: _SubParsersAct
163163

164164
def start(self) -> None:
165165
"""
166-
Delegate to :meth:`~trinity.extensibility.plugin.BasePlugin._start` and set ``running``
166+
Delegate to :meth:`~trinity.extensibility.plugin.BasePlugin.do_start` and set ``running``
167167
to ``True``. Broadcast a :class:`~trinity.extensibility.events.PluginStartedEvent` on the
168168
:class:`~lahja.eventbus.EventBus` and hence allow other plugins to act accordingly.
169169
"""
170170
self.running = True
171-
self._start()
171+
self.do_start()
172172
self.event_bus.broadcast(
173173
PluginStartedEvent(type(self))
174174
)
175175
self.logger.info("Plugin started: %s", self.name)
176176

177-
def _start(self) -> None:
177+
def do_start(self) -> None:
178178
"""
179179
Perform the actual plugin start routine. In the case of a `BaseIsolatedPlugin` this method
180180
will be called in a separate process.
@@ -190,18 +190,18 @@ class BaseSyncStopPlugin(BasePlugin):
190190
A :class:`~trinity.extensibility.plugin.BaseSyncStopPlugin` unwinds synchronoulsy, hence blocks
191191
until the shutdown is done.
192192
"""
193-
def _stop(self) -> None:
193+
def do_stop(self) -> None:
194194
"""
195195
Stop the plugin. Should be overwritten by subclasses.
196196
"""
197197
pass
198198

199199
def stop(self) -> None:
200200
"""
201-
Delegate to :meth:`~trinity.extensibility.plugin.BaseSyncStopPlugin._stop` causing the
201+
Delegate to :meth:`~trinity.extensibility.plugin.BaseSyncStopPlugin.do_stop` causing the
202202
plugin to stop and setting ``running`` to ``False``.
203203
"""
204-
self._stop()
204+
self.do_stop()
205205
self.running = False
206206

207207

@@ -211,18 +211,18 @@ class BaseAsyncStopPlugin(BasePlugin):
211211
needs to be awaited.
212212
"""
213213

214-
async def _stop(self) -> None:
214+
async def do_stop(self) -> None:
215215
"""
216216
Asynchronously stop the plugin. Should be overwritten by subclasses.
217217
"""
218218
pass
219219

220220
async def stop(self) -> None:
221221
"""
222-
Delegate to :meth:`~trinity.extensibility.plugin.BaseAsyncStopPlugin._stop` causing the
222+
Delegate to :meth:`~trinity.extensibility.plugin.BaseAsyncStopPlugin.do_stop` causing the
223223
plugin to stop asynchronously and setting ``running`` to ``False``.
224224
"""
225-
await self._stop()
225+
await self.do_stop()
226226
self.running = False
227227

228228

@@ -250,7 +250,7 @@ class BaseIsolatedPlugin(BaseSyncStopPlugin):
250250

251251
def start(self) -> None:
252252
"""
253-
Prepare the plugin to get started and eventually call ``_start`` in a separate process.
253+
Prepare the plugin to get started and eventually call ``do_start`` in a separate process.
254254
"""
255255
self.running = True
256256
self._process = ctx.Process(
@@ -268,9 +268,9 @@ def _prepare_start(self) -> None:
268268
self.event_bus.broadcast(
269269
PluginStartedEvent(type(self))
270270
)
271-
self._start()
271+
self.do_start()
272272

273-
def _stop(self) -> None:
273+
def do_stop(self) -> None:
274274
self.context.event_bus.stop()
275275
kill_process_gracefully(self._process, self.logger)
276276

@@ -290,7 +290,7 @@ def configure_parser(self, arg_parser: ArgumentParser, subparser: _SubParsersAct
290290
def handle_event(self, activation_event: BaseEvent) -> None:
291291
self.logger.info("Debug plugin: handle_event called: %s", activation_event)
292292

293-
def _start(self) -> None:
293+
def do_start(self) -> None:
294294
self.logger.info("Debug plugin: start called")
295295
asyncio.ensure_future(self.count_forever())
296296

@@ -301,5 +301,5 @@ async def count_forever(self) -> None:
301301
i += 1
302302
await asyncio.sleep(1)
303303

304-
async def _stop(self) -> None:
304+
async def do_stop(self) -> None:
305305
self.logger.info("Debug plugin: stop called")

trinity/plugins/builtin/ethstats/plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def ready(self) -> None:
103103

104104
self.start()
105105

106-
def _start(self) -> None:
106+
def do_start(self) -> None:
107107
service = EthstatsService(
108108
self.context,
109109
self.server_url,

trinity/plugins/builtin/json_rpc/plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def configure_parser(self, arg_parser: ArgumentParser, subparser: _SubParsersAct
4444
help="Disables the JSON-RPC Server",
4545
)
4646

47-
def _start(self) -> None:
47+
def do_start(self) -> None:
4848
db_manager = create_db_manager(self.context.trinity_config.database_ipc_path)
4949
db_manager.connect()
5050

trinity/plugins/builtin/light_peer_chain_bridge/plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ def handle_event(self, event: ResourceAvailableEvent) -> None:
5757
self.chain = event.resource
5858
self.start()
5959

60-
def _start(self) -> None:
60+
def do_start(self) -> None:
6161
chain = cast(LightDispatchChain, self.chain)
6262
self.handler = LightPeerChainEventBusHandler(chain._peer_chain, self.context.event_bus)
6363
asyncio.ensure_future(self.handler.run())
6464

65-
async def _stop(self) -> None:
65+
async def do_stop(self) -> None:
6666
# This isn't really needed for the standard shutdown case as the LightPeerChain will
6767
# automatically shutdown whenever the `CancelToken` it was chained with is triggered.
6868
# It may still be useful to stop the LightPeerChain Bridge plugin individually though.

trinity/plugins/builtin/tx_pool/plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def handle_event(self, event: ResourceAvailableEvent) -> None:
7878
if all((self.peer_pool is not None, self.chain is not None, self.is_enabled)):
7979
self.start()
8080

81-
def _start(self) -> None:
81+
def do_start(self) -> None:
8282
if isinstance(self.chain, BaseMainnetChain):
8383
validator = DefaultTransactionValidator(self.chain, BYZANTIUM_MAINNET_BLOCK)
8484
elif isinstance(self.chain, BaseRopstenChain):
@@ -91,7 +91,7 @@ def _start(self) -> None:
9191
self.tx_pool = TxPool(self.peer_pool, validator, self.cancel_token)
9292
asyncio.ensure_future(self.tx_pool.run())
9393

94-
async def _stop(self) -> None:
94+
async def do_stop(self) -> None:
9595
# This isn't really needed for the standard shutdown case as the TxPool will automatically
9696
# shutdown whenever the `CancelToken` it was chained with is triggered. It may still be
9797
# useful to stop the TxPool plugin individually though.

trinity/plugins/builtin/tx_pool/pool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,5 @@ def _add_txs_to_bloom(self, peer: ETHPeer, txs: Iterable[BaseTransactionFields])
122122
for val in txs:
123123
self._bloom.add(self._construct_bloom_entry(peer, val))
124124

125-
async def _cleanup(self) -> None:
125+
async def do_cleanup(self) -> None:
126126
self.logger.info("Stopping Tx Pool...")

0 commit comments

Comments
 (0)