def call_sync(func):
@wraps(func)<EOL>def wrapper(self, *args, **kw):<EOL><INDENT>"""<STR_LIT>"""<EOL>if self.thread.ident == get_ident():<EOL><INDENT>return func(self, *args, **kw)<EOL><DEDENT>barrier = Barrier(<NUM_LIT:2>)<EOL>result = None<EOL>ex = None<EOL>def call():<EOL><INDENT>"""<STR_LIT>"""<EOL>nonlocal result, ex<EOL>try:<EOL><INDENT>result = func(self, *args, **kw)<EOL><DEDENT>except Exception as exc:<EOL><INDENT>ex = exc<EOL><DEDENT>finally:<EOL><INDENT>barrier.wait()<EOL><DEDENT><DEDENT>self.loop.call_soon_threadsafe(call)<EOL>barrier.wait()<EOL>if ex:<EOL><INDENT>raise ex or Exception("<STR_LIT>")<EOL><DEDENT>return result<EOL><DEDENT>return wrapper<EOL>
Decorates a function to be called sync on the loop thread