From 7e25ca4c84bb00fa264b3c8b658e148a15a0e8f1 Mon Sep 17 00:00:00 2001 From: Swann Date: Thu, 26 Nov 2020 11:37:51 +0100 Subject: [PATCH] feat: show exit reason in the disconnection popup --- multi_user/__init__.py | 2 +- multi_user/delayable.py | 4 ++-- multi_user/operators.py | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/multi_user/__init__.py b/multi_user/__init__.py index c7f1688..9de2790 100644 --- a/multi_user/__init__.py +++ b/multi_user/__init__.py @@ -44,7 +44,7 @@ from . import environment DEPENDENCIES = { - ("replication", '0.1.13'), + ("replication", '0.1.15'), } diff --git a/multi_user/delayable.py b/multi_user/delayable.py index 9de641f..5e120fc 100644 --- a/multi_user/delayable.py +++ b/multi_user/delayable.py @@ -358,6 +358,6 @@ class MainThreadExecutor(Timer): def execute(self): while not self.execution_queue.empty(): - function = self.execution_queue.get() + function, kwargs = self.execution_queue.get() logging.debug(f"Executing {function.__name__}") - function() + function(**kwargs) diff --git a/multi_user/operators.py b/multi_user/operators.py index a280dd3..5d98861 100644 --- a/multi_user/operators.py +++ b/multi_user/operators.py @@ -53,8 +53,8 @@ def session_callback(name): """ def func_wrapper(func): @session.register(name) - def add_background_task(): - background_execution_queue.put(func) + def add_background_task(**kwargs): + background_execution_queue.put((func, kwargs)) return add_background_task return func_wrapper @@ -89,7 +89,7 @@ def initialize_session(): @session_callback('on_exit') -def on_connection_end(): +def on_connection_end(reason="none"): """Session connection finished handler """ global delayables, stop_modal_executor @@ -113,8 +113,8 @@ def on_connection_end(): for handler in logger.handlers: if isinstance(handler, logging.FileHandler): logger.removeHandler(handler) - - bpy.ops.session.notify('INVOKE_DEFAULT', message="Disconnected from server") + if reason != "user": + bpy.ops.session.notify('INVOKE_DEFAULT', message=f"Disconnected from session. Reason: {reason}. ") # OPERATORS @@ -704,7 +704,7 @@ class SessionNotifyOperator(bpy.types.Operator): def invoke(self, context, event): - return context.window_manager.invoke_popup(self, width=200) + return context.window_manager.invoke_popup(self, width=300) classes = (