- My extension's initialize() and shutdown() are logged numerous times.
- This is contrary to the documentation which says that initialize should only fire when an extension is enabled and shutdown should only fire when disabled and/or the server is shut down.
- My ReviewBoardApprovalHook is_approved is logged 1-3 times.
- Expect that this should only fire 1x?
The problem gets worse if I disable my extension. Once disabled, I continue to see logs related to my extension's shutdown and is_approved until I restart apache. If I toggle my extension on and off, the number of is_approved calls continues to grow.
It seems as though these hooks are not getting properly removed when the extension is disabled (despite what the documentation says). Possibly made worse because the extension is being initialized/shutdown multiple times per page render?
I did make one change to explicitly disable the ReviewRequestApprovalHook that I added in my extension's shutdown. This seemed to reduce the is_approved checks to only 1 per page render (and none once the extension is disabled), but I still see the extension being enabled/disabled multiple times and I suspect that is the true cause of this issue?
Any help/thoughts are greatly appreciated.
from reviewboard.extensions.base import Extension
from reviewboard.extensions.hooks import ReviewRequestApprovalHook
import logging
class ApprovalRulesExtension(Extension):
def initialize(self):
self.approval_hook = TestApprovalHook(self)
logging.debug("Enabling ApprovalRulesExtension")
def shutdown(self):
self.approval_hook.disable_hook()
logging.debug("Disabling ApprovalRulesExtension")
class TestApprovalHook(ReviewRequestApprovalHook):
def is_approved(self, review_request, prev_approved, prev_failure):
logging.debug('checking is_approved')
return True
Thanks,
Travis