Skip to content

Commit

Permalink
Uninstall default bottle plugins
Browse files Browse the repository at this point in the history
By default, bottle installs two plugins: `JSONPlugin` and `TemplatePlugin`.

`TemplatePlugin` is always a no-op, because none of the routes we use
(like `/ready`) have a template parameter.

`JSONPlugin` could have been useful were it actually serializing all json
messages. Instead it only deals with dictionaries. Ycmd has always had
`ycmd.handlers._JsonResponse` and we will need to keep it that way.
`_JsonResponse` makes `JSONPlugin` a no-op too, because, by the time we get
to the `JSONPlugin.apply()` the response is always a str already.

`Bottle.uninstall()` can be passed:

1. An instance of an installed plugins, to uninstall that one plugin.
2. A type, to uninstall all plugins of that type.
3. `True`, to uninstall all plugins.

Since we are uninstalling all default plugins, we can just do

`handlers.app.uninstall( True )` and then install the plugins we care
about - `ycmd.HmacPlugin` and `ycmd.WatchdogPlugin`.
  • Loading branch information
bstaletic committed Feb 14, 2024
1 parent b8957d7 commit e6b3a56
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions ycmd/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ def Main():
args.stderr,
args.keep_logfiles )
atexit.register( handlers.ServerCleanup )
handlers.app.uninstall( True )
handlers.app.install( WatchdogPlugin( args.idle_suicide_seconds,
args.check_interval_seconds ) )
handlers.app.install( HmacPlugin( hmac_secret ) )
Expand Down

0 comments on commit e6b3a56

Please sign in to comment.