Skip to content

Bot.run does not return when stop is called #517

Open
@M4tyr0

Description

@M4tyr0

Describe the bug
I am currently running the Bot in a different thread via the following code which works well:

 # Activate Eventloop for current thread
class MMThread():
def run(self, ...)
        self.loop = asyncio.new_event_loop()
        asyncio.set_event_loop(self.loop)

        self.bot = Bot(
            settings=Settings(
                MATTERMOST_URL = "URL",
                MATTERMOST_PORT = 443,
                BOT_TOKEN = self.api_token, #@cluster-bot
                BOT_TEAM = "...",
                SSL_VERIFY = True,
            ),  # Either specify your settings here or as environment variables.
            plugins=[HelpPlugin(),                   
                    StatusPlugin(...)],  # Add your own plugins here.
        )   
        self.bot.run()

def start(self):
    self.thread = threading.Thread(target=self.run, args=()) 

def stop(self):
    self.bot.stop()
    self.thread.join()

How To Reproduce
Give us simple steps to reproduce the behavior:

Expected behavior
I expect for bot.run to return after everything is shutdown internally and the thread to join.

Operating Environment (please complete the following information):

  • mmpy_bot Version: 2.1.4
  • mattermostdriver/mattermostautodriver Version: 1.2.2
  • Mattermost Server Version: -
  • Python Version: 3.10.12
  • OS: Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions