Mercurial > libervia-backend
comparison src/bridge/DBus.py @ 424:72c13313b6d6
bridge: added check that synchronous method does not return a deferred
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 07 Nov 2011 22:27:07 +0100 |
parents | 6c20c76abdcc |
children | e4e9187e3b5b |
comparison
equal
deleted
inserted
replaced
423:6c20c76abdcc | 424:72c13313b6d6 |
---|---|
39 class InternalError(dbus.DBusException): | 39 class InternalError(dbus.DBusException): |
40 _dbus_error_name = const_ERROR_PREFIX + ".InternalError" | 40 _dbus_error_name = const_ERROR_PREFIX + ".InternalError" |
41 | 41 |
42 class AsyncNotDeferred(dbus.DBusException): | 42 class AsyncNotDeferred(dbus.DBusException): |
43 _dbus_error_name = const_ERROR_PREFIX + ".AsyncNotDeferred" | 43 _dbus_error_name = const_ERROR_PREFIX + ".AsyncNotDeferred" |
44 | |
45 class DeferredNotAsync(dbus.DBusException): | |
46 _dbus_error_name = const_ERROR_PREFIX + ".DeferredNotAsync" | |
44 | 47 |
45 class GenericException(dbus.DBusException): | 48 class GenericException(dbus.DBusException): |
46 def __init__(self, twisted_error): | 49 def __init__(self, twisted_error): |
47 super(GenericException,self).__init__() | 50 super(GenericException,self).__init__() |
48 mess = twisted_error.getErrorMessage() | 51 mess = twisted_error.getErrorMessage() |
80 error("Asynchrone method [%s] does not return a Deferred." % name) | 83 error("Asynchrone method [%s] does not return a Deferred." % name) |
81 raise AsyncNotDeferred | 84 raise AsyncNotDeferred |
82 result.addCallback(callback) | 85 result.addCallback(callback) |
83 result.addErrback(lambda err:errback(GenericException(err))) | 86 result.addErrback(lambda err:errback(GenericException(err))) |
84 else: | 87 else: |
88 if isinstance(result, Deferred): | |
89 error("Synchrone method [%s] return a Deferred." % name) | |
90 raise DeferredNotAsync | |
85 return result | 91 return result |
86 | 92 |
87 ### signals ### | 93 ### signals ### |
88 | 94 |
89 @dbus.service.signal(const_INT_PREFIX+const_PLUGIN_SUFFIX, | 95 @dbus.service.signal(const_INT_PREFIX+const_PLUGIN_SUFFIX, |