diff --git a/python/examples/test_examples.py b/python/examples/test_examples.py index da32b127d..c9c38c26d 100644 --- a/python/examples/test_examples.py +++ b/python/examples/test_examples.py @@ -3,7 +3,7 @@ import pytest import py import echo_and_quit import group_tracking -from deltachat.eventlogger import FFIEventLogger +from deltachat.events import FFIEventLogger @pytest.fixture(scope='session') @@ -17,16 +17,23 @@ def datadir(): pytest.skip('test-data directory not found') -def test_echo_quit_plugin(acfactory): +def test_echo_quit_plugin(acfactory, lp): + lp.sec("creating one echo_and_quit bot") botproc = acfactory.run_bot_process(echo_and_quit) + lp.sec("creating a temp account to contact the bot") ac1 = acfactory.get_one_online_account() + + lp.sec("sending a message to the bot") bot_contact = ac1.create_contact(botproc.addr) ch1 = ac1.create_chat_by_contact(bot_contact) ch1.send_text("hello") + + lp.sec("waiting for the bot-reply to arrive") reply = ac1._evtracker.wait_next_incoming_message() assert "hello" in reply.text assert reply.chat == ch1 + lp.sec("send quit sequence") ch1.send_text("/quit") botproc.wait() diff --git a/python/src/deltachat/account.py b/python/src/deltachat/account.py index 8b8f01741..54761fada 100644 --- a/python/src/deltachat/account.py +++ b/python/src/deltachat/account.py @@ -636,6 +636,7 @@ class Account(object): self._shutdown_event.set() hook = hookspec.Global._get_plugin_manager().hook hook.dc_account_after_shutdown(account=self, dc_context=dc_context) + self.log("shutdown finished") def _destroy_dc_context(dc_context, dc_context_unref=lib.dc_context_unref): diff --git a/python/src/deltachat/events.py b/python/src/deltachat/events.py index bd23e3359..95007ca7c 100644 --- a/python/src/deltachat/events.py +++ b/python/src/deltachat/events.py @@ -147,6 +147,10 @@ class EventThread(threading.Thread): self._thread_quitflag = True if wait: + if self == threading.current_thread(): + # we are in the callback thread and thus cannot + # wait for the thread-loop to finish. + return self.join() def run(self):