summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2017-06-01 09:26:44 +0200
committerBenoit Foucher <benoit@zeroc.com>2017-06-01 09:26:44 +0200
commit19077d22e78f93212445c6969045e736b4a466d7 (patch)
tree484d4b0dc9a791c9f8f0c4b3dbf212856aba1f55 /python
parentUpdated recursive mutex check (diff)
downloadice-19077d22e78f93212445c6969045e736b4a466d7.tar.bz2
ice-19077d22e78f93212445c6969045e736b4a466d7.tar.xz
ice-19077d22e78f93212445c6969045e736b4a466d7.zip
Fixed ICE-7941 - scheduleCallback now provides the connection to the dispatcher work item, fixed naming of AsyncResult private methods
Diffstat (limited to 'python')
-rw-r--r--python/modules/IcePy/Operation.cpp2
-rw-r--r--python/python/Ice/__init__.py8
-rw-r--r--python/test/Ice/ami/AllTests.py49
3 files changed, 56 insertions, 3 deletions
diff --git a/python/modules/IcePy/Operation.cpp b/python/modules/IcePy/Operation.cpp
index 3b51db4bdfd..c75512de517 100644
--- a/python/modules/IcePy/Operation.cpp
+++ b/python/modules/IcePy/Operation.cpp
@@ -1134,7 +1134,7 @@ asyncResultCallLater(AsyncResultObject* self, PyObject* args)
try
{
- (*self->result)->scheduleCallback(new CallbackI(callback));
+ (*self->result)->_scheduleCallback(new CallbackI(callback));
}
catch(const Ice::CommunicatorDestroyedException& ex)
{
diff --git a/python/python/Ice/__init__.py b/python/python/Ice/__init__.py
index a167f54dde5..d159feb3fc6 100644
--- a/python/python/Ice/__init__.py
+++ b/python/python/Ice/__init__.py
@@ -223,12 +223,18 @@ class InvocationFuture(Future):
return Future.cancel(self)
def add_done_callback_async(self, fn):
+ def callback(future):
+ try:
+ callback(future)
+ except:
+ logging.getLogger("Ice.Future").exception('callback raised exception')
+
with self._condition:
if self._state == Future.StateRunning:
self._doneCallbacks.append(fn)
return
if self._asyncResult:
- self._asyncResult.callLater(lambda: fn(self))
+ self._asyncResult.callLater(callback)
else:
fn(self)
diff --git a/python/test/Ice/ami/AllTests.py b/python/test/Ice/ami/AllTests.py
index 36d20450bf7..3b8a902a8e5 100644
--- a/python/test/Ice/ami/AllTests.py
+++ b/python/test/Ice/ami/AllTests.py
@@ -7,7 +7,7 @@
#
# **********************************************************************
-import Ice, Test, sys, threading, random
+import Ice, Test, sys, threading, random, logging
def test(b):
if not b:
@@ -373,6 +373,11 @@ class Thrower(CallbackBase):
throwEx(self._t)
def allTests(communicator, collocated):
+ # Ice.Future uses the Python logging facility, this tests throws exceptions from Ice.Future callbacks
+ # so we disable errors to prevent them to show up on the console.
+ logging.basicConfig()
+ logging.disable(logging.ERROR)
+
sref = "test:default -p 12010"
obj = communicator.stringToProxy(sref)
test(obj)
@@ -708,18 +713,60 @@ def allTests(communicator, collocated):
p.begin_op(cb.op, cb.noEx)
cb.check()
+ def thrower(future):
+ try:
+ future.result()
+ except:
+ test(false)
+ throwEx(t)
+ f = p.opAsync()
+ f.add_done_callback(thrower)
+ f.add_done_callback_async(thrower)
+ f.result()
+
p.begin_op(lambda: cb.opWC(cookie), lambda ex: cb.noExWC(ex, cookie))
cb.check()
q.begin_op(cb.op, cb.ex)
cb.check()
+ f = q.opAsync()
+ def throwerEx(future):
+ try:
+ future.result()
+ test(false)
+ except:
+ throwEx(t)
+ try:
+ f.add_done_callback(throwerEx)
+ except Exception as ex:
+ try:
+ throwEx(t)
+ except Exception as ex2:
+ test(type(ex) == type(ex2))
+ f.add_done_callback_async(throwerEx)
+ try:
+ f.result()
+ except:
+ pass
+
q.begin_op(lambda: cb.opWC(cookie), lambda ex: cb.exWC(ex, cookie))
cb.check()
p.begin_op(cb.noOp, cb.ex, cb.sent)
cb.check()
+ f = p.opAsync()
+ try:
+ f.add_sent_callback(lambda f, s: throwEx(t))
+ except Exception as ex:
+ try:
+ throwEx(t)
+ except Exception as ex2:
+ test(type(ex) == type(ex2))
+ #f.add_sent_callback_async(throwerSent)
+ f.result()
+
p.begin_op(lambda: cb.noOpWC(cookie), lambda ex: cb.exWC(ex, cookie), lambda ss: cb.sentWC(ss, cookie))
cb.check()