diff src/bridge/bridge_constructor/bridge_constructor.py @ 1237:c1e916594e09

bridge (frontends side): fixed call of async method in blocking context
author Goffi <goffi@goffi.org>
date Thu, 16 Oct 2014 20:18:40 +0200
parents d123d61976c8
children faa1129559b8
line wrap: on
line diff
--- a/src/bridge/bridge_constructor/bridge_constructor.py	Thu Oct 16 20:10:08 2014 +0200
+++ b/src/bridge/bridge_constructor/bridge_constructor.py	Thu Oct 16 20:18:40 2014 +0200
@@ -450,12 +450,13 @@
                 completion['args_result'] = self.getArguments(function['sig_in'], name=arg_doc)
                 completion['async_args'] = 'callback=None, errback=None' if async else ''
                 completion['async_comma'] = ', ' if async and function['sig_in'] else ''
-                completion['async_args_result'] = 'timeout=const_TIMEOUT, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err))' if async else ''
+                completion['error_handler'] = ("error_handler = None if callback is None else lambda err:errback(dbus_to_bridge_exception(err))\n" + 8*" ") if async else ''
+                completion['async_args_result'] = 'timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler' if async else ''
                 result = "self.db_%(category)s_iface.%(name)s(%(args_result)s%(async_comma)s%(async_args_result)s)" % completion
                 completion['result'] = ("unicode(%s)" if self.options.unicode and function['sig_out'] == 's' else "%s") % result
                 methods_part.append("""\
     def %(name)s(self, %(args)s%(async_comma)s%(async_args)s):
-        %(debug)sreturn %(result)s
+        %(error_handler)s%(debug)sreturn %(result)s
 """ % completion)
 
         #at this point, methods_part should be filled,