Mercurial > libervia-backend
comparison 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 |
comparison
equal
deleted
inserted
replaced
1236:251ae99a6c0e | 1237:c1e916594e09 |
---|---|
448 if function["type"] == "method": | 448 if function["type"] == "method": |
449 completion['debug'] = "" if not self.options.debug else 'log.debug ("%s")\n%s' % (section, 8 * ' ') | 449 completion['debug'] = "" if not self.options.debug else 'log.debug ("%s")\n%s' % (section, 8 * ' ') |
450 completion['args_result'] = self.getArguments(function['sig_in'], name=arg_doc) | 450 completion['args_result'] = self.getArguments(function['sig_in'], name=arg_doc) |
451 completion['async_args'] = 'callback=None, errback=None' if async else '' | 451 completion['async_args'] = 'callback=None, errback=None' if async else '' |
452 completion['async_comma'] = ', ' if async and function['sig_in'] else '' | 452 completion['async_comma'] = ', ' if async and function['sig_in'] else '' |
453 completion['async_args_result'] = 'timeout=const_TIMEOUT, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err))' if async else '' | 453 completion['error_handler'] = ("error_handler = None if callback is None else lambda err:errback(dbus_to_bridge_exception(err))\n" + 8*" ") if async else '' |
454 completion['async_args_result'] = 'timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler' if async else '' | |
454 result = "self.db_%(category)s_iface.%(name)s(%(args_result)s%(async_comma)s%(async_args_result)s)" % completion | 455 result = "self.db_%(category)s_iface.%(name)s(%(args_result)s%(async_comma)s%(async_args_result)s)" % completion |
455 completion['result'] = ("unicode(%s)" if self.options.unicode and function['sig_out'] == 's' else "%s") % result | 456 completion['result'] = ("unicode(%s)" if self.options.unicode and function['sig_out'] == 's' else "%s") % result |
456 methods_part.append("""\ | 457 methods_part.append("""\ |
457 def %(name)s(self, %(args)s%(async_comma)s%(async_args)s): | 458 def %(name)s(self, %(args)s%(async_comma)s%(async_args)s): |
458 %(debug)sreturn %(result)s | 459 %(error_handler)s%(debug)sreturn %(result)s |
459 """ % completion) | 460 """ % completion) |
460 | 461 |
461 #at this point, methods_part should be filled, | 462 #at this point, methods_part should be filled, |
462 #we just have to place it in the right part of the template | 463 #we just have to place it in the right part of the template |
463 frontend_bridge = [] | 464 frontend_bridge = [] |