mark2devel / mark2

Minecraft Multi Server Wrapper Written in Python with Twisted; Pull Requests HIGHLY Encouraged, Collaborators Needed Discord: https://discord.gg/zymJygHNpv
Other
205 stars 44 forks source link

Cannot cancel a scheduled restart #152

Closed Column01 closed 3 months ago

Column01 commented 2 years ago

image

Column01 commented 1 year ago

I can't for the life of me figure out why this happens, sometimes it works fine to cancel a restart and other times it doesn't work at all

edk0 commented 1 year ago

Shutdown's self.cancel doesn't get adjusted when one of the delayed events actually happens. That seems like a bug, and it could be the root cause of this.

Column01 commented 1 year ago

Ahh I see, this seems to be the case. I can probably work something out where if it tries to cancel an ready completed event it just goes back and tries the next queue item until it either cancels something or the queue is empty

Column01 commented 1 year ago

If a server restarts multiple times those cancel events potentially build up over time too as far as I can tell. Might need to implement something that clears the queue of completed events instead of the other idea

Column01 commented 3 months ago

Shutdown's self.cancel doesn't get adjusted when one of the delayed events actually happens. That seems like a bug, and it could be the root cause of this.

I know this is kind of old at this point but I'm looking into it and the actual error comes here

Am I stupid to think I could just fix this by checking if the task is active before trying to cancel it? Or should I be looking at fixing what you mentioned where the events are not cleared in shutdown. Cause it seems to me this could happen for any task that is being run in a plugin that can be cancelled

def cancel(*args):
    if delayed_call[0].active():
        delayed_call[0].cancel()
        if callbackCancel:
            callbackCancel(*args)
Column01 commented 3 months ago

I was correct in my assumption, should push a fix here in a bit