I am running into the same situation as Petr. I have noticed the same 
behavior plus some other concerns (that I believe Petr's logs also show).

I put logging into my extension initialize, shutdown, and is_approved. When 
I enable my plugin and visit a RB page:

   - 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

On Friday, April 17, 2020 at 5:59:24 AM UTC-4, Petr Grenar wrote:
>
> Hello,
>
> I have a running extension that is finally doing what I want :) But there 
> is one thing that I don't understand. The extension is working with 
> SignalHook review_request_closed and a SampleApprovalHook. So when someone 
> put ship it and submitted on review request the extension is called. This 
> is working. But when I go to the apache log I can see that the extension 
> was called multiple times with the same result. Is this behavior normal or 
> am I doing something wrong?
>
> The extension is calling other stuff but the log was the same even before 
> I was calling the other things.
>
> You can see the log output and extension on the attached images.
>
> [image: log.png]
>
> [image: extension.png]
>
>
> Thank you in advance.
>
> Petr Grenar
>

-- 
Supercharge your Review Board with Power Pack: 
https://www.reviewboard.org/powerpack/
Want us to host Review Board for you? Check out RBCommons: 
https://rbcommons.com/
Happy user? Let us know! https://www.reviewboard.org/users/
--- 
You received this message because you are subscribed to the Google Groups 
"Review Board Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/reviewboard/115aa918-95e3-421c-923e-83684b7386cd%40googlegroups.com.

Reply via email to