summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/modules/IcePy/Connection.cpp233
-rw-r--r--python/modules/IcePy/Util.cpp4
-rw-r--r--python/test/Ice/acm/AllTests.py23
-rw-r--r--python/test/Ice/acm/Test.ice3
-rw-r--r--python/test/Ice/acm/TestI.py42
-rw-r--r--python/test/Ice/ami/AllTests.py170
-rwxr-xr-xpython/test/Ice/ami/Client.py1
-rwxr-xr-xpython/test/Ice/ami/Server.py4
-rw-r--r--python/test/Ice/ami/Test.ice10
-rw-r--r--python/test/Ice/ami/TestI.py9
-rw-r--r--python/test/Ice/binding/AllTests.py26
-rw-r--r--python/test/Ice/location/AllTests.py74
-rw-r--r--python/test/Ice/operations/BatchOneways.py4
-rw-r--r--python/test/Ice/operations/BatchOnewaysAMI.py4
-rw-r--r--python/test/Ice/operations/BatchOnewaysFuture.py4
-rw-r--r--python/test/Ice/timeout/AllTests.py76
16 files changed, 493 insertions, 194 deletions
diff --git a/python/modules/IcePy/Connection.cpp b/python/modules/IcePy/Connection.cpp
index ec1e4f8db68..8e9e9286d02 100644
--- a/python/modules/IcePy/Connection.cpp
+++ b/python/modules/IcePy/Connection.cpp
@@ -37,18 +37,18 @@ struct ConnectionObject
Ice::CommunicatorPtr* communicator;
};
-class CloseCallbackI : public Ice::CloseCallback
+class CloseCallbackWrapper : public Ice::CloseCallback
{
public:
- CloseCallbackI(PyObject* cb, PyObject* con) :
+ CloseCallbackWrapper(PyObject* cb, PyObject* con) :
_cb(cb), _con(con)
{
Py_INCREF(cb);
Py_INCREF(con);
}
- virtual ~CloseCallbackI()
+ virtual ~CloseCallbackWrapper()
{
AdoptThread adoptThread; // Ensure the current thread is able to call into Python.
@@ -94,18 +94,18 @@ private:
PyObject* _con;
};
-class HeartbeatCallbackI : public Ice::HeartbeatCallback
+class HeartbeatCallbackWrapper : public Ice::HeartbeatCallback
{
public:
- HeartbeatCallbackI(PyObject* cb, PyObject* con) :
+ HeartbeatCallbackWrapper(PyObject* cb, PyObject* con) :
_cb(cb), _con(con)
{
Py_INCREF(cb);
Py_INCREF(con);
}
- virtual ~HeartbeatCallbackI()
+ virtual ~HeartbeatCallbackWrapper()
{
AdoptThread adoptThread; // Ensure the current thread is able to call into Python.
@@ -151,6 +151,62 @@ private:
PyObject* _con;
};
+class HeartbeatAsyncCallback : public IceUtil::Shared
+{
+public:
+
+ HeartbeatAsyncCallback(PyObject* ex, PyObject* sent, const string& op) :
+ _ex(ex), _sent(sent), _op(op)
+ {
+ assert(_ex);
+ Py_INCREF(_ex);
+ Py_XINCREF(_sent);
+ }
+
+ ~HeartbeatAsyncCallback()
+ {
+ AdoptThread adoptThread; // Ensure the current thread is able to call into Python.
+
+ Py_DECREF(_ex);
+ Py_XDECREF(_sent);
+ }
+
+ void exception(const Ice::Exception& ex)
+ {
+ AdoptThread adoptThread; // Ensure the current thread is able to call into Python.
+
+ PyObjectHandle exh = convertException(ex);
+ assert(exh.get());
+ PyObjectHandle args = Py_BuildValue(STRCAST("(O)"), exh.get());
+ PyObjectHandle tmp = PyObject_Call(_ex, args.get(), 0);
+ if(PyErr_Occurred())
+ {
+ throwPythonException(); // Callback raised an exception.
+ }
+ }
+
+ void sent(bool sentSynchronously)
+ {
+ if(_sent)
+ {
+ AdoptThread adoptThread; // Ensure the current thread is able to call into Python.
+ PyObjectHandle args = Py_BuildValue(STRCAST("(O)"), sentSynchronously ? getTrue() : getFalse());
+ PyObjectHandle tmp = PyObject_Call(_sent, args.get(), 0);
+ if(PyErr_Occurred())
+ {
+ throwPythonException(); // Callback raised an exception.
+ }
+ }
+ }
+
+protected:
+
+ PyObject* _ex;
+ PyObject* _sent;
+ std::string _op;
+};
+typedef IceUtil::Handle<HeartbeatAsyncCallback> HeartbeatAsyncCallbackPtr;
+
}
#ifdef WIN32
@@ -241,17 +297,22 @@ extern "C"
static PyObject*
connectionClose(ConnectionObject* self, PyObject* args)
{
- int force;
- if(!PyArg_ParseTuple(args, STRCAST("i"), &force))
+ PyObject* closeType = lookupType("Ice.ConnectionClose");
+ PyObject* mode;
+ if(!PyArg_ParseTuple(args, STRCAST("O!"), closeType, &mode))
{
return 0;
}
+ PyObjectHandle v = PyObject_GetAttrString(mode, STRCAST("_value"));
+ assert(v.get());
+ Ice::ConnectionClose cc = static_cast<Ice::ConnectionClose>(PyLong_AsLong(v.get()));
+
assert(self->connection);
try
{
AllowThreads allowThreads; // Release Python's global interpreter lock during blocking invocations.
- (*self->connection)->close(force > 0);
+ (*self->connection)->close(cc);
}
catch(const Ice::Exception& ex)
{
@@ -532,7 +593,7 @@ connectionSetCloseCallback(ConnectionObject* self, PyObject* args)
return 0;
}
- Ice::CloseCallbackPtr wrapper = new CloseCallbackI(cb, reinterpret_cast<PyObject*>(self));
+ Ice::CloseCallbackPtr wrapper = new CloseCallbackWrapper(cb, reinterpret_cast<PyObject*>(self));
try
{
AllowThreads allowThreads; // Release Python's global interpreter lock during blocking invocations.
@@ -563,7 +624,7 @@ connectionSetHeartbeatCallback(ConnectionObject* self, PyObject* args)
return 0;
}
- Ice::HeartbeatCallbackPtr wrapper = new HeartbeatCallbackI(cb, reinterpret_cast<PyObject*>(self));
+ Ice::HeartbeatCallbackPtr wrapper = new HeartbeatCallbackWrapper(cb, reinterpret_cast<PyObject*>(self));
try
{
AllowThreads allowThreads; // Release Python's global interpreter lock during blocking invocations.
@@ -583,6 +644,127 @@ connectionSetHeartbeatCallback(ConnectionObject* self, PyObject* args)
extern "C"
#endif
static PyObject*
+connectionHeartbeat(ConnectionObject* self)
+{
+ assert(self->connection);
+ try
+ {
+ AllowThreads allowThreads; // Release Python's global interpreter lock during remote invocations.
+ (*self->connection)->heartbeat();
+ }
+ catch(const Ice::Exception& ex)
+ {
+ setPythonException(ex);
+ return 0;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+#ifdef WIN32
+extern "C"
+#endif
+static PyObject*
+connectionBeginHeartbeat(ConnectionObject* self, PyObject* args, PyObject* kwds)
+{
+ assert(self->connection);
+
+ static char* argNames[] =
+ {
+ const_cast<char*>("_ex"),
+ const_cast<char*>("_sent"),
+ 0
+ };
+ PyObject* ex = Py_None;
+ PyObject* sent = Py_None;
+ if(!PyArg_ParseTupleAndKeywords(args, kwds, STRCAST("|OO"), argNames, &ex, &sent))
+ {
+ return 0;
+ }
+
+ if(ex == Py_None)
+ {
+ ex = 0;
+ }
+ if(sent == Py_None)
+ {
+ sent = 0;
+ }
+
+ if(!ex && sent)
+ {
+ PyErr_Format(PyExc_RuntimeError,
+ STRCAST("exception callback must also be provided when sent callback is used"));
+ return 0;
+ }
+
+ Ice::Callback_Connection_heartbeatPtr cb;
+ if(ex || sent)
+ {
+ HeartbeatAsyncCallbackPtr d = new HeartbeatAsyncCallback(ex, sent, "heartbeat");
+ cb = Ice::newCallback_Connection_heartbeat(d, &HeartbeatAsyncCallback::exception,
+ &HeartbeatAsyncCallback::sent);
+ }
+
+ Ice::AsyncResultPtr result;
+ try
+ {
+ AllowThreads allowThreads; // Release Python's global interpreter lock during remote invocations.
+
+ if(cb)
+ {
+ result = (*self->connection)->begin_heartbeat(cb);
+ }
+ else
+ {
+ result = (*self->connection)->begin_heartbeat();
+ }
+ }
+ catch(const Ice::Exception& ex)
+ {
+ setPythonException(ex);
+ return 0;
+ }
+
+ PyObjectHandle communicator = getCommunicatorWrapper(*self->communicator);
+ return createAsyncResult(result, 0, reinterpret_cast<PyObject*>(self), communicator.get());
+}
+
+#ifdef WIN32
+extern "C"
+#endif
+static PyObject*
+connectionEndHeartbeat(ConnectionObject* self, PyObject* args)
+{
+ assert(self->connection);
+
+ PyObject* result;
+ if(!PyArg_ParseTuple(args, STRCAST("O!"), &AsyncResultType, &result))
+ {
+ return 0;
+ }
+
+ Ice::AsyncResultPtr r = getAsyncResult(result);
+ try
+ {
+ AllowThreads allowThreads; // Release Python's global interpreter lock during blocking invocations.
+ (*self->connection)->end_flushBatchRequests(r);
+ }
+ catch(const Ice::Exception& ex)
+ {
+ setPythonException(ex);
+ return 0;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+#ifdef WIN32
+extern "C"
+#endif
+static PyObject*
connectionSetACM(ConnectionObject* self, PyObject* args)
{
assert(self->connection);
@@ -853,6 +1035,27 @@ connectionSetBufferSize(ConnectionObject* self, PyObject* args)
return Py_None;
}
+#ifdef WIN32
+extern "C"
+#endif
+static PyObject*
+connectionThrowException(ConnectionObject* self)
+{
+ assert(self->connection);
+ try
+ {
+ (*self->connection)->throwException();
+ }
+ catch(const Ice::Exception& ex)
+ {
+ setPythonException(ex);
+ return 0;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
static PyMethodDef ConnectionMethods[] =
{
{ STRCAST("close"), reinterpret_cast<PyCFunction>(connectionClose), METH_VARARGS,
@@ -875,6 +1078,12 @@ static PyMethodDef ConnectionMethods[] =
PyDoc_STR(STRCAST("setCloseCallback(Ice.CloseCallback) -> None")) },
{ STRCAST("setHeartbeatCallback"), reinterpret_cast<PyCFunction>(connectionSetHeartbeatCallback), METH_VARARGS,
PyDoc_STR(STRCAST("setHeartbeatCallback(Ice.HeartbeatCallback) -> None")) },
+ { STRCAST("heartbeat"), reinterpret_cast<PyCFunction>(connectionHeartbeat), METH_NOARGS,
+ PyDoc_STR(STRCAST("heartbeat() -> None")) },
+ { STRCAST("begin_heartbeat"), reinterpret_cast<PyCFunction>(connectionBeginHeartbeat),
+ METH_VARARGS | METH_KEYWORDS, PyDoc_STR(STRCAST("begin_heartbeat([_ex][, _sent]) -> Ice.AsyncResult")) },
+ { STRCAST("end_heartbeat"), reinterpret_cast<PyCFunction>(connectionEndHeartbeat), METH_VARARGS,
+ PyDoc_STR(STRCAST("end_heartbeat(Ice.AsyncResult) -> None")) },
{ STRCAST("setACM"), reinterpret_cast<PyCFunction>(connectionSetACM), METH_VARARGS,
PyDoc_STR(STRCAST("setACM(int, Ice.ACMClose, Ice.ACMHeartbeat) -> None")) },
{ STRCAST("getACM"), reinterpret_cast<PyCFunction>(connectionGetACM), METH_NOARGS,
@@ -891,6 +1100,8 @@ static PyMethodDef ConnectionMethods[] =
PyDoc_STR(STRCAST("getEndpoint() -> Ice.Endpoint")) },
{ STRCAST("setBufferSize"), reinterpret_cast<PyCFunction>(connectionSetBufferSize), METH_VARARGS,
PyDoc_STR(STRCAST("setBufferSize(int, int) -> None")) },
+ { STRCAST("throwException"), reinterpret_cast<PyCFunction>(connectionThrowException), METH_NOARGS,
+ PyDoc_STR(STRCAST("throwException() -> None")) },
{ 0, 0 } /* sentinel */
};
diff --git a/python/modules/IcePy/Util.cpp b/python/modules/IcePy/Util.cpp
index 953bbee84a0..c3b8f18462c 100644
--- a/python/modules/IcePy/Util.cpp
+++ b/python/modules/IcePy/Util.cpp
@@ -857,6 +857,10 @@ convertLocalException(const Ice::LocalException& ex, PyObject* p)
IcePy::PyObjectHandle m = IcePy::createString(e.reason);
PyObject_SetAttrString(p, STRCAST("reason"), m.get());
}
+ catch(const Ice::ConnectionManuallyClosedException& e)
+ {
+ PyObject_SetAttrString(p, STRCAST("graceful"), e.graceful ? IcePy::getTrue() : IcePy::getFalse());
+ }
catch(const Ice::LocalException&)
{
//
diff --git a/python/test/Ice/acm/AllTests.py b/python/test/Ice/acm/AllTests.py
index c10edd1de77..1c7bb57709b 100644
--- a/python/test/Ice/acm/AllTests.py
+++ b/python/test/Ice/acm/AllTests.py
@@ -294,6 +294,25 @@ def allTests(communicator):
with self.m:
test(self._heartbeat >= 3)
+ class HeartbeatManualTest(TestCase):
+ def __init__(self, com):
+ TestCase.__init__(self, "manual heartbeats", com)
+ #
+ # Disable heartbeats.
+ #
+ self.setClientACM(10, -1, 0)
+ self.setServerACM(10, -1, 0)
+
+ def runTestCase(self, adapter, proxy):
+ proxy.startHeartbeatCount()
+ con = proxy.ice_getConnection()
+ con.heartbeat()
+ con.heartbeat()
+ con.heartbeat()
+ con.heartbeat()
+ con.heartbeat()
+ proxy.waitForHeartbeatCount(5)
+
class SetACMTest(TestCase):
def __init__(self, com):
TestCase.__init__(self, "setACM/getACM", com)
@@ -318,7 +337,8 @@ def allTests(communicator):
test(acm.close == Ice.ACMClose.CloseOnInvocationAndIdle)
test(acm.heartbeat == Ice.ACMHeartbeat.HeartbeatAlways)
- proxy.waitForHeartbeat(2)
+ proxy.startHeartbeatCount()
+ proxy.waitForHeartbeatCount(2)
tests.append(InvocationHeartbeatTest(com))
tests.append(InvocationHeartbeatOnHoldTest(com))
@@ -332,6 +352,7 @@ def allTests(communicator):
tests.append(HeartbeatOnIdleTest(com))
tests.append(HeartbeatAlwaysTest(com))
+ tests.append(HeartbeatManualTest(com))
tests.append(SetACMTest(com))
for p in tests:
diff --git a/python/test/Ice/acm/Test.ice b/python/test/Ice/acm/Test.ice
index 5ab98180dd3..d78abd6eb0f 100644
--- a/python/test/Ice/acm/Test.ice
+++ b/python/test/Ice/acm/Test.ice
@@ -17,7 +17,8 @@ interface TestIntf
void sleep(int seconds);
void sleepAndHold(int seconds);
void interruptSleep();
- void waitForHeartbeat(int count);
+ void startHeartbeatCount();
+ void waitForHeartbeatCount(int count);
};
interface RemoteObjectAdapter
diff --git a/python/test/Ice/acm/TestI.py b/python/test/Ice/acm/TestI.py
index 10565ca9540..41f5afe93eb 100644
--- a/python/test/Ice/acm/TestI.py
+++ b/python/test/Ice/acm/TestI.py
@@ -9,6 +9,21 @@
import Ice, Test, threading
+class ConnectionCallbackI():
+ def __init__(self):
+ self.m = threading.Condition()
+ self.count = 0
+
+ def heartbeat(self, con):
+ with self.m:
+ self.count += 1
+ self.m.notifyAll()
+
+ def waitForCount(self, count):
+ with self.m:
+ while self.count < count:
+ self.m.wait()
+
class RemoteCommunicatorI(Test._RemoteCommunicatorDisp):
def createObjectAdapter(self, timeout, close, heartbeat, current=None):
com = current.adapter.getCommunicator()
@@ -68,26 +83,9 @@ class TestIntfI(Test._TestIntfDisp):
with self.m:
self.m.notifyAll()
- def waitForHeartbeat(self, count, current=None):
-
- class ConnectionCallbackI():
-
- def __init__(self):
- self.m = threading.Condition()
- self.count = 0
-
- def heartbeat(self, con):
- with self.m:
- self.count -= 1
- self.m.notifyAll()
-
- def waitForCount(self, count):
- with self.m:
- self.count = count
- while self.count > 0:
- self.m.wait()
-
- callback = ConnectionCallbackI()
- current.con.setHeartbeatCallback(lambda con: callback.heartbeat(con))
- callback.waitForCount(2)
+ def startHeartbeatCount(self, current=None):
+ self.callback = ConnectionCallbackI()
+ current.con.setHeartbeatCallback(lambda con: self.callback.heartbeat(con))
+ def waitForHeartbeatCount(self, count, current=None):
+ self.callback.waitForCount(2)
diff --git a/python/test/Ice/ami/AllTests.py b/python/test/Ice/ami/AllTests.py
index 549915ee12e..71d6237b61a 100644
--- a/python/test/Ice/ami/AllTests.py
+++ b/python/test/Ice/ami/AllTests.py
@@ -769,7 +769,7 @@ def allTests(communicator, collocated):
test(p.opBatchCount() == 0)
b1 = p.ice_batchOneway()
b1.opBatch()
- b1.ice_getConnection().close(False)
+ b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
cb = FlushCallback()
r = b1.begin_ice_flushBatchRequests(cb.exception, cb.sent)
cb.check()
@@ -783,7 +783,7 @@ def allTests(communicator, collocated):
test(p.opBatchCount() == 0)
b1 = p.ice_batchOneway()
b1.opBatch()
- b1.ice_getConnection().close(False)
+ b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
cb = FlushCallback(cookie)
r = b1.begin_ice_flushBatchRequests(lambda ex: cb.exceptionWC(ex, cookie), lambda ss: cb.sentWC(ss, cookie))
cb.check()
@@ -830,7 +830,7 @@ def allTests(communicator, collocated):
test(p.opBatchCount() == 0)
b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway())
b1.opBatch()
- b1.ice_getConnection().close(False)
+ b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
cb = FlushExCallback()
r = b1.ice_getConnection().begin_flushBatchRequests(cb.exception, cb.sent)
cb.check()
@@ -844,7 +844,7 @@ def allTests(communicator, collocated):
test(p.opBatchCount() == 0)
b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway())
b1.opBatch()
- b1.ice_getConnection().close(False)
+ b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
cb = FlushExCallback(cookie)
r = b1.ice_getConnection().begin_flushBatchRequests(lambda ex: cb.exceptionWC(ex, cookie),
lambda ss: cb.sentWC(ss, cookie))
@@ -876,7 +876,7 @@ def allTests(communicator, collocated):
test(p.opBatchCount() == 0)
b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway())
b1.opBatch()
- b1.ice_getConnection().close(False)
+ b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
cb = FlushCallback()
r = communicator.begin_flushBatchRequests(cb.exception, cb.sent)
cb.check()
@@ -916,7 +916,7 @@ def allTests(communicator, collocated):
b2.ice_getConnection() # Ensure connection is established.
b1.opBatch()
b2.opBatch()
- b1.ice_getConnection().close(False)
+ b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
cb = FlushCallback()
r = communicator.begin_flushBatchRequests(cb.exception, cb.sent)
cb.check()
@@ -936,8 +936,8 @@ def allTests(communicator, collocated):
b2.ice_getConnection() # Ensure connection is established.
b1.opBatch()
b2.opBatch()
- b1.ice_getConnection().close(False)
- b2.ice_getConnection().close(False)
+ b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
+ b2.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
cb = FlushCallback()
r = communicator.begin_flushBatchRequests(cb.exception, cb.sent)
cb.check()
@@ -1120,9 +1120,27 @@ def allTests(communicator, collocated):
print("ok")
if p.ice_getConnection():
- sys.stdout.write("testing close connection with sending queue... ")
+ sys.stdout.write("testing graceful close connection with wait... ")
sys.stdout.flush()
+ #
+ # Local case: begin several requests, close the connection gracefully, and make sure it waits
+ # for the requests to complete.
+ #
+ results = []
+ for i in range(0, 3):
+ results.append(p.begin_sleep(50))
+ p.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
+ for r in results:
+ r.waitForCompleted()
+ try:
+ r.throwLocalException()
+ except:
+ test(False)
+
+ #
+ # Remote case.
+ #
if sys.version_info[0] == 2:
b = [chr(random.randint(0, 255)) for x in range(0, 10*1024)]
seq = ''.join(b)
@@ -1143,7 +1161,7 @@ def allTests(communicator, collocated):
results = []
for i in range(0, maxQueue):
results.append(p.begin_opWithPayload(seq))
- if not p.begin_close(False).isSent():
+ if not p.begin_close(Test.CloseMode.CloseGracefullyAndWait).isSent():
for i in range(0, maxQueue):
r = p.begin_opWithPayload(seq)
results.append(r)
@@ -1163,6 +1181,83 @@ def allTests(communicator, collocated):
print("ok")
+ sys.stdout.write("testing graceful close connection without wait... ")
+ sys.stdout.flush()
+
+ #
+ # Local case: start a lengthy operation and then close the connection gracefully on the client side
+ # without waiting for the pending invocation to complete. There will be no retry and we expect the
+ # invocation to fail with ConnectionManuallyClosedException.
+ #
+ # This test requires two threads in the server's thread pool: one will block in sleep() and the other
+ # will process the CloseConnection message.
+ #
+ p.ice_ping()
+ con = p.ice_getConnection()
+ r = p.begin_sleep(1000)
+ con.close(Ice.ConnectionClose.CloseGracefully)
+ r.waitForCompleted()
+ try:
+ r.throwLocalException()
+ test(False)
+ except Ice.ConnectionManuallyClosedException, ex:
+ test(ex.graceful)
+
+ #
+ # Remote case: the server closes the connection gracefully. Our call to TestIntf::close()
+ # completes successfully and then the connection should be closed immediately afterward,
+ # despite the fact that there's a pending call to sleep(). The call to sleep() should be
+ # automatically retried and complete successfully.
+ #
+ p.ice_ping()
+ con = p.ice_getConnection()
+ cb = CallbackBase()
+ con.setCloseCallback(lambda c: cb.called())
+ r = p.begin_sleep(250)
+ p.close(Test.CloseMode.CloseGracefully)
+ cb.check()
+ r.waitForCompleted()
+ try:
+ r.throwLocalException()
+ except:
+ test(false)
+ p.ice_ping()
+ test(p.ice_getConnection() != con)
+
+ print("ok")
+
+ sys.stdout.write("testing forceful close connection... ")
+ sys.stdout.flush()
+
+ #
+ # Local case: start a lengthy operation and then close the connection forcefully on the client side.
+ # There will be no retry and we expect the invocation to fail with ConnectionManuallyClosedException.
+ #
+ p.ice_ping()
+ con = p.ice_getConnection()
+ r = p.begin_sleep(100)
+ con.close(Ice.ConnectionClose.CloseForcefully)
+ r.waitForCompleted()
+ try:
+ r.throwLocalException()
+ test(False)
+ except Ice.ConnectionManuallyClosedException, ex:
+ test(not ex.graceful)
+
+ #
+ # Remote case: the server closes the connection forcefully. This causes the request to fail
+ # with a ConnectionLostException. Since the close() operation is not idempotent, the client
+ # will not retry.
+ #
+ try:
+ p.close(Test.CloseMode.CloseForcefully)
+ test(False)
+ except Ice.ConnectionLostException:
+ # Expected.
+ pass
+
+ print("ok")
+
def allTestsFuture(communicator, collocated):
sref = "test:default -p 12010"
obj = communicator.stringToProxy(sref)
@@ -1404,7 +1499,7 @@ def allTestsFuture(communicator, collocated):
test(p.opBatchCount() == 0)
b1 = p.ice_batchOneway()
b1.opBatch()
- b1.ice_getConnection().close(False)
+ b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
cb = FutureFlushCallback()
f = b1.ice_flushBatchRequestsAsync()
f.add_sent_callback(cb.sent)
@@ -1436,7 +1531,7 @@ def allTestsFuture(communicator, collocated):
test(p.opBatchCount() == 0)
b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway())
b1.opBatch()
- b1.ice_getConnection().close(False)
+ b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
cb = FutureFlushExCallback()
f = b1.ice_getConnection().flushBatchRequestsAsync()
f.add_done_callback(cb.exception)
@@ -1473,7 +1568,7 @@ def allTestsFuture(communicator, collocated):
test(p.opBatchCount() == 0)
b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway())
b1.opBatch()
- b1.ice_getConnection().close(False)
+ b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
cb = FutureFlushCallback()
f = communicator.flushBatchRequestsAsync()
f.add_sent_callback(cb.sent)
@@ -1517,7 +1612,7 @@ def allTestsFuture(communicator, collocated):
b2.ice_getConnection() # Ensure connection is established.
b1.opBatch()
b2.opBatch()
- b1.ice_getConnection().close(False)
+ b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
cb = FutureFlushCallback()
f = communicator.flushBatchRequestsAsync()
f.add_sent_callback(cb.sent)
@@ -1539,8 +1634,8 @@ def allTestsFuture(communicator, collocated):
b2.ice_getConnection() # Ensure connection is established.
b1.opBatch()
b2.opBatch()
- b1.ice_getConnection().close(False)
- b2.ice_getConnection().close(False)
+ b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
+ b2.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
cb = FutureFlushCallback()
f = communicator.flushBatchRequestsAsync()
f.add_sent_callback(cb.sent)
@@ -1723,47 +1818,4 @@ def allTestsFuture(communicator, collocated):
print("ok")
- if p.ice_getConnection():
- sys.stdout.write("testing close connection with sending queue... ")
- sys.stdout.flush()
-
- if sys.version_info[0] == 2:
- b = [chr(random.randint(0, 255)) for x in range(0, 10*1024)]
- seq = ''.join(b)
- else:
- b = [random.randint(0, 255) for x in range(0, 10*1024)]
- seq = bytes(b)
-
- #
- # Send multiple opWithPayload, followed by a close and followed by multiple opWithPaylod.
- # The goal is to make sure that none of the opWithPayload fail even if the server closes
- # the connection gracefully in between.
- #
- maxQueue = 2
- done = False
- while not done and maxQueue < 50:
- done = True
- p.ice_ping()
- results = []
- for i in range(0, maxQueue):
- results.append(p.opWithPayloadAsync(seq))
- if not p.closeAsync(False).is_sent():
- for i in range(0, maxQueue):
- f = p.opWithPayloadAsync(seq)
- results.append(f)
- if f.is_sent():
- done = False
- maxQueue = maxQueue * 2
- break
- else:
- maxQueue = maxQueue * 2
- done = False
- for f in results:
- try:
- f.result()
- except Ice.LocalException:
- test(False)
-
- print("ok")
-
p.shutdown()
diff --git a/python/test/Ice/ami/Client.py b/python/test/Ice/ami/Client.py
index 1966ff4bd6d..6fa2db022ca 100755
--- a/python/test/Ice/ami/Client.py
+++ b/python/test/Ice/ami/Client.py
@@ -33,6 +33,7 @@ try:
initData = Ice.InitializationData()
initData.properties = Ice.createProperties(sys.argv)
initData.properties.setProperty('Ice.Warn.AMICallback', '0')
+ initData.properties.setProperty('Ice.Warn.Connections', '0')
#
# Limit the send buffer size, this test relies on the socket
diff --git a/python/test/Ice/ami/Server.py b/python/test/Ice/ami/Server.py
index 1872276ecb0..a042727fc01 100755
--- a/python/test/Ice/ami/Server.py
+++ b/python/test/Ice/ami/Server.py
@@ -44,13 +44,13 @@ try:
#
# This test kills connections, so we don't want warnings.
#
- initData.properties.setProperty("Ice.Warn.Connections", "0");
+ initData.properties.setProperty("Ice.Warn.Connections", "0")
#
# Limit the recv buffer size, this test relies on the socket
# send() blocking after sending a given amount of data.
#
- initData.properties.setProperty("Ice.TCP.RcvSize", "50000");
+ initData.properties.setProperty("Ice.TCP.RcvSize", "50000")
with Ice.initialize(sys.argv, initData) as communicator:
status = run(sys.argv, communicator)
diff --git a/python/test/Ice/ami/Test.ice b/python/test/Ice/ami/Test.ice
index 4bda44b5c41..9787dd9a1fc 100644
--- a/python/test/Ice/ami/Test.ice
+++ b/python/test/Ice/ami/Test.ice
@@ -19,6 +19,13 @@ exception TestIntfException
{
};
+enum CloseMode
+{
+ CloseForcefully,
+ CloseGracefully,
+ CloseGracefullyAndWait
+};
+
interface TestIntf
{
void op();
@@ -29,7 +36,8 @@ interface TestIntf
void opBatch();
int opBatchCount();
bool waitForBatch(int count);
- void close(bool force);
+ void close(CloseMode mode);
+ void sleep(int ms);
void shutdown();
bool supportsFunctionalTests();
diff --git a/python/test/Ice/ami/TestI.py b/python/test/Ice/ami/TestI.py
index 3770a2c6101..53585189f29 100644
--- a/python/test/Ice/ami/TestI.py
+++ b/python/test/Ice/ami/TestI.py
@@ -7,7 +7,7 @@
#
# **********************************************************************
-import Ice, Test, threading
+import Ice, Test, threading, time
class TestIntfI(Test._TestIntfDisp):
def __init__(self):
@@ -43,8 +43,11 @@ class TestIntfI(Test._TestIntfDisp):
self._batchCount = 0
return result
- def close(self, force, current=None):
- current.con.close(force)
+ def close(self, mode, current=None):
+ current.con.close(Ice.ConnectionClose.valueOf(mode.value))
+
+ def sleep(self, ms, current=None):
+ time.sleep(ms / 1000.0)
def shutdown(self, current=None):
current.adapter.getCommunicator().shutdown()
diff --git a/python/test/Ice/binding/AllTests.py b/python/test/Ice/binding/AllTests.py
index b877fc78ac5..5bf5a02a801 100644
--- a/python/test/Ice/binding/AllTests.py
+++ b/python/test/Ice/binding/AllTests.py
@@ -110,7 +110,7 @@ def allTests(communicator):
name = test1.getAdapterName()
if names.count(name) > 0:
names.remove(name)
- test1.ice_getConnection().close(False)
+ test1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
#
# Ensure that the proxy correctly caches the connection (we
@@ -128,7 +128,7 @@ def allTests(communicator):
test(i == nRetry)
for a in adapters:
- a.getTestIntf().ice_getConnection().close(False)
+ a.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
#
# Deactivate an adapter and ensure that we can still
@@ -152,7 +152,7 @@ def allTests(communicator):
name = test1.getAdapterName()
if names.count(name) > 0:
names.remove(name)
- test1.ice_getConnection().close(False)
+ test1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
#
# Deactivate an adapter and ensure that we can still
@@ -194,7 +194,7 @@ def allTests(communicator):
name = getAdapterNameWithAMI(test1)
if names.count(name) > 0:
names.remove(name)
- test1.ice_getConnection().close(False)
+ test1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
#
# Ensure that the proxy correctly caches the connection (we
@@ -212,7 +212,7 @@ def allTests(communicator):
test(i == nRetry)
for a in adapters:
- a.getTestIntf().ice_getConnection().close(False)
+ a.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
#
# Deactivate an adapter and ensure that we can still
@@ -236,7 +236,7 @@ def allTests(communicator):
name = getAdapterNameWithAMI(test1)
if names.count(name) > 0:
names.remove(name)
- test1.ice_getConnection().close(False)
+ test1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
#
# Deactivate an adapter and ensure that we can still
@@ -266,7 +266,7 @@ def allTests(communicator):
name = t.getAdapterName()
if names.count(name) > 0:
names.remove(name)
- t.ice_getConnection().close(False)
+ t.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
t = Test.TestIntfPrx.uncheckedCast(t.ice_endpointSelection(Ice.EndpointSelectionType.Random))
test(t.ice_getEndpointSelection() == Ice.EndpointSelectionType.Random)
@@ -278,7 +278,7 @@ def allTests(communicator):
name = t.getAdapterName()
if names.count(name) > 0:
names.remove(name)
- t.ice_getConnection().close(False)
+ t.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
deactivate(com, adapters)
@@ -337,13 +337,13 @@ def allTests(communicator):
while i < nRetry and t.getAdapterName() == "Adapter36":
i = i + 1
test(i == nRetry)
- t.ice_getConnection().close(False)
+ t.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
adapters.append(com.createObjectAdapter("Adapter35", endpoints[1].toString()))
i = 0
while i < nRetry and t.getAdapterName() == "Adapter35":
i = i + 1
test(i == nRetry)
- t.ice_getConnection().close(False)
+ t.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
adapters.append(com.createObjectAdapter("Adapter34", endpoints[0].toString()))
i = 0
while i < nRetry and t.getAdapterName() == "Adapter34":
@@ -618,7 +618,7 @@ def allTests(communicator):
t = createTestIntfPrx(adapters)
for i in range(0, 5):
test(t.getAdapterName() == "Adapter82")
- t.ice_getConnection().close(False)
+ t.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
testSecure = Test.TestIntfPrx.uncheckedCast(t.ice_secure(True))
test(testSecure.ice_isSecure())
@@ -632,13 +632,13 @@ def allTests(communicator):
for i in range(0, 5):
test(t.getAdapterName() == "Adapter81")
- t.ice_getConnection().close(False)
+ t.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
com.createObjectAdapter("Adapter83", (t.ice_getEndpoints()[1]).toString()) # Reactive tcp OA.
for i in range(0, 5):
test(t.getAdapterName() == "Adapter83")
- t.ice_getConnection().close(False)
+ t.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
com.deactivateObjectAdapter(adapters[0])
try:
diff --git a/python/test/Ice/location/AllTests.py b/python/test/Ice/location/AllTests.py
index dc0fb5afe5d..205ae91329d 100644
--- a/python/test/Ice/location/AllTests.py
+++ b/python/test/Ice/location/AllTests.py
@@ -22,8 +22,8 @@ def allTests(communicator, ref):
locator = communicator.getDefaultLocator()
test(manager)
- registry = Test.TestLocatorRegistryPrx.checkedCast(locator.getRegistry());
- test(registry);
+ registry = Test.TestLocatorRegistryPrx.checkedCast(locator.getRegistry())
+ test(registry)
sys.stdout.write("testing stringToProxy... ")
sys.stdout.flush()
@@ -36,34 +36,34 @@ def allTests(communicator, ref):
sys.stdout.write("testing ice_locator and ice_getLocator... ")
sys.stdout.flush()
- test(Ice.proxyIdentityEqual(base.ice_getLocator(), communicator.getDefaultLocator()));
- anotherLocator = Ice.LocatorPrx.uncheckedCast(communicator.stringToProxy("anotherLocator"));
- base = base.ice_locator(anotherLocator);
- test(Ice.proxyIdentityEqual(base.ice_getLocator(), anotherLocator));
- communicator.setDefaultLocator(None);
- base = communicator.stringToProxy("test @ TestAdapter");
- test(not base.ice_getLocator());
- base = base.ice_locator(anotherLocator);
- test(Ice.proxyIdentityEqual(base.ice_getLocator(), anotherLocator));
- communicator.setDefaultLocator(locator);
- base = communicator.stringToProxy("test @ TestAdapter");
- test(Ice.proxyIdentityEqual(base.ice_getLocator(), communicator.getDefaultLocator()));
+ test(Ice.proxyIdentityEqual(base.ice_getLocator(), communicator.getDefaultLocator()))
+ anotherLocator = Ice.LocatorPrx.uncheckedCast(communicator.stringToProxy("anotherLocator"))
+ base = base.ice_locator(anotherLocator)
+ test(Ice.proxyIdentityEqual(base.ice_getLocator(), anotherLocator))
+ communicator.setDefaultLocator(None)
+ base = communicator.stringToProxy("test @ TestAdapter")
+ test(not base.ice_getLocator())
+ base = base.ice_locator(anotherLocator)
+ test(Ice.proxyIdentityEqual(base.ice_getLocator(), anotherLocator))
+ communicator.setDefaultLocator(locator)
+ base = communicator.stringToProxy("test @ TestAdapter")
+ test(Ice.proxyIdentityEqual(base.ice_getLocator(), communicator.getDefaultLocator()))
#
# We also test ice_router/ice_getRouter (perhaps we should add a
# test/Ice/router test?)
#
- test(not base.ice_getRouter());
- anotherRouter = Ice.RouterPrx.uncheckedCast(communicator.stringToProxy("anotherRouter"));
- base = base.ice_router(anotherRouter);
- test(Ice.proxyIdentityEqual(base.ice_getRouter(), anotherRouter));
- router = Ice.RouterPrx.uncheckedCast(communicator.stringToProxy("dummyrouter"));
- communicator.setDefaultRouter(router);
- base = communicator.stringToProxy("test @ TestAdapter");
- test(Ice.proxyIdentityEqual(base.ice_getRouter(), communicator.getDefaultRouter()));
- communicator.setDefaultRouter(None);
- base = communicator.stringToProxy("test @ TestAdapter");
- test(not base.ice_getRouter());
+ test(not base.ice_getRouter())
+ anotherRouter = Ice.RouterPrx.uncheckedCast(communicator.stringToProxy("anotherRouter"))
+ base = base.ice_router(anotherRouter)
+ test(Ice.proxyIdentityEqual(base.ice_getRouter(), anotherRouter))
+ router = Ice.RouterPrx.uncheckedCast(communicator.stringToProxy("dummyrouter"))
+ communicator.setDefaultRouter(router)
+ base = communicator.stringToProxy("test @ TestAdapter")
+ test(Ice.proxyIdentityEqual(base.ice_getRouter(), communicator.getDefaultRouter()))
+ communicator.setDefaultRouter(None)
+ base = communicator.stringToProxy("test @ TestAdapter")
+ test(not base.ice_getRouter())
print("ok")
sys.stdout.write("starting server... ")
@@ -200,7 +200,7 @@ def allTests(communicator, ref):
sys.stdout.flush()
hello = Test.HelloPrx.checkedCast(communicator.stringToProxy("hello"))
obj.migrateHello()
- hello.ice_getConnection().close(False);
+ hello.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
hello.sayHello()
obj.migrateHello()
hello.sayHello()
@@ -237,21 +237,21 @@ def allTests(communicator, ref):
#
sys.stdout.write("testing indirect references to collocated objects... ")
sys.stdout.flush()
- properties = communicator.getProperties();
- properties.setProperty("Ice.PrintAdapterReady", "0");
- adapter = communicator.createObjectAdapterWithEndpoints("Hello", "default");
- adapter.setLocator(locator);
+ properties = communicator.getProperties()
+ properties.setProperty("Ice.PrintAdapterReady", "0")
+ adapter = communicator.createObjectAdapterWithEndpoints("Hello", "default")
+ adapter.setLocator(locator)
assert(adapter.getLocator() == locator)
- id = Ice.Identity();
- id.name = Ice.generateUUID();
- registry.addObject(adapter.add(HelloI(), id));
- adapter.activate();
+ id = Ice.Identity()
+ id.name = Ice.generateUUID()
+ registry.addObject(adapter.add(HelloI(), id))
+ adapter.activate()
- helloPrx = Test.HelloPrx.checkedCast(communicator.stringToProxy(communicator.identityToString(id)));
- test(not helloPrx.ice_getConnection());
+ helloPrx = Test.HelloPrx.checkedCast(communicator.stringToProxy(Ice.identityToString(id)))
+ test(not helloPrx.ice_getConnection())
- adapter.deactivate();
+ adapter.deactivate()
print("ok")
sys.stdout.write("shutdown server manager... ")
diff --git a/python/test/Ice/operations/BatchOneways.py b/python/test/Ice/operations/BatchOneways.py
index 5878ff7f7af..ea0fc26c29c 100644
--- a/python/test/Ice/operations/BatchOneways.py
+++ b/python/test/Ice/operations/BatchOneways.py
@@ -82,7 +82,7 @@ def batchOneways(p):
batch1.ice_ping()
batch2.ice_ping()
batch1.ice_flushBatchRequests()
- batch1.ice_getConnection().close(False)
+ batch1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
batch1.ice_ping()
batch2.ice_ping()
@@ -90,7 +90,7 @@ def batchOneways(p):
batch2.ice_getConnection()
batch1.ice_ping()
- batch1.ice_getConnection().close(False)
+ batch1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
batch1.ice_ping()
batch2.ice_ping()
diff --git a/python/test/Ice/operations/BatchOnewaysAMI.py b/python/test/Ice/operations/BatchOnewaysAMI.py
index cd53ee94470..f750b3eb02d 100644
--- a/python/test/Ice/operations/BatchOnewaysAMI.py
+++ b/python/test/Ice/operations/BatchOnewaysAMI.py
@@ -61,14 +61,14 @@ def batchOneways(p):
batch1.end_ice_ping(batch1.begin_ice_ping())
batch2.end_ice_ping(batch2.begin_ice_ping())
batch1.end_ice_flushBatchRequests(batch1.begin_ice_flushBatchRequests())
- batch1.ice_getConnection().close(False)
+ batch1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
batch1.end_ice_ping(batch1.begin_ice_ping())
batch2.end_ice_ping(batch2.begin_ice_ping())
batch1.ice_getConnection()
batch2.ice_getConnection()
- batch1.ice_getConnection().close(False)
+ batch1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
batch1.end_ice_ping(batch1.begin_ice_ping())
batch2.end_ice_ping(batch2.begin_ice_ping())
diff --git a/python/test/Ice/operations/BatchOnewaysFuture.py b/python/test/Ice/operations/BatchOnewaysFuture.py
index ccf84220aa1..ea1c70bcf94 100644
--- a/python/test/Ice/operations/BatchOnewaysFuture.py
+++ b/python/test/Ice/operations/BatchOnewaysFuture.py
@@ -63,14 +63,14 @@ def batchOneways(p):
batch1.ice_pingAsync()
batch2.ice_pingAsync()
batch1.ice_flushBatchRequestsAsync().result()
- batch1.ice_getConnection().close(False)
+ batch1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
batch1.ice_pingAsync()
batch2.ice_pingAsync()
batch1.ice_getConnection()
batch2.ice_getConnection()
- batch1.ice_getConnection().close(False)
+ batch1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait)
test(not batch1.ice_pingAsync().done())
test(not batch2.ice_pingAsync().done())
diff --git a/python/test/Ice/timeout/AllTests.py b/python/test/Ice/timeout/AllTests.py
index 16d3d0484f8..391c6b23ca5 100644
--- a/python/test/Ice/timeout/AllTests.py
+++ b/python/test/Ice/timeout/AllTests.py
@@ -116,58 +116,58 @@ def allTests(communicator):
sys.stdout.write("testing invocation timeout... ")
sys.stdout.flush()
- connection = obj.ice_getConnection();
- to = Test.TimeoutPrx.uncheckedCast(obj.ice_invocationTimeout(100));
- test(connection == to.ice_getConnection());
+ connection = obj.ice_getConnection()
+ to = Test.TimeoutPrx.uncheckedCast(obj.ice_invocationTimeout(100))
+ test(connection == to.ice_getConnection())
try:
- to.sleep(750);
- test(False);
+ to.sleep(750)
+ test(False)
except Ice.InvocationTimeoutException:
pass
- obj.ice_ping();
- to = Test.TimeoutPrx.uncheckedCast(obj.ice_invocationTimeout(500));
- test(connection == to.ice_getConnection());
+ obj.ice_ping()
+ to = Test.TimeoutPrx.uncheckedCast(obj.ice_invocationTimeout(500))
+ test(connection == to.ice_getConnection())
try:
- to.sleep(250);
+ to.sleep(250)
except Ice.InvocationTimeoutException:
- test(False);
- test(connection == to.ice_getConnection());
+ test(False)
+ test(connection == to.ice_getConnection())
# #
# # Expect InvocationTimeoutException.
# #
- # to = Test.TimeoutPrx.uncheckedCast(obj.ice_invocationTimeout(250));
- # cb = new Callback();
- # to.begin_sleep(750, newCallback_Timeout_sleep(cb, &Callback.responseEx, &Callback.exceptionEx));
- # cb.check();
+ # to = Test.TimeoutPrx.uncheckedCast(obj.ice_invocationTimeout(250))
+ # cb = new Callback()
+ # to.begin_sleep(750, newCallback_Timeout_sleep(cb, &Callback.responseEx, &Callback.exceptionEx))
+ # cb.check()
# #
# # Expect success.
# #
- # to = Test.TimeoutPrx.uncheckedCast(obj.ice_invocationTimeout(500));
- # cb = new Callback();
- # to.begin_sleep(250, newCallback_Timeout_sleep(cb, &Callback.response, &Callback.exception));
- # cb.check();
+ # to = Test.TimeoutPrx.uncheckedCast(obj.ice_invocationTimeout(500))
+ # cb = new Callback()
+ # to.begin_sleep(250, newCallback_Timeout_sleep(cb, &Callback.response, &Callback.exception))
+ # cb.check()
print("ok")
sys.stdout.write("testing close timeout... ")
sys.stdout.flush()
- to = Test.TimeoutPrx.checkedCast(obj.ice_timeout(100));
- connection = to.ice_getConnection();
- timeout.holdAdapter(500);
- connection.close(False);
+ to = Test.TimeoutPrx.checkedCast(obj.ice_timeout(100))
+ connection = to.ice_getConnection()
+ timeout.holdAdapter(500)
+ connection.close(Ice.ConnectionClose.CloseGracefullyAndWait)
try:
connection.getInfo(); # getInfo() doesn't throw in the closing state.
except Ice.LocalException:
- test(False);
- time.sleep(0.5);
+ test(False)
+ time.sleep(0.5)
try:
- connection.getInfo();
- test(False);
- except Ice.CloseConnectionException:
+ connection.getInfo()
+ test(False)
+ except Ice.ConnectionManuallyClosedException, ex:
# Expected.
- pass
- timeout.op(); # Ensure adapter is active.
+ test(ex.graceful)
+ timeout.op() # Ensure adapter is active.
print("ok")
sys.stdout.write("testing timeout overrides... ")
@@ -193,7 +193,7 @@ def allTests(communicator):
#
timeout.op() # Ensure adapter is active.
to = Test.TimeoutPrx.checkedCast(to.ice_timeout(1000))
- timeout.holdAdapter(500);
+ timeout.holdAdapter(500)
try:
to.sendData(seq)
test(False)
@@ -229,9 +229,9 @@ def allTests(communicator):
# Verify that timeout set via ice_timeout() is still used for requests.
#
timeout.op() # Ensure adapter is active.
- to = Test.TimeoutPrx.uncheckedCast(to.ice_timeout(250));
+ to = Test.TimeoutPrx.uncheckedCast(to.ice_timeout(250))
to.ice_getConnection(); # Establish connection
- timeout.holdAdapter(750);
+ timeout.holdAdapter(750)
try:
to.sendData(seq)
test(False)
@@ -246,11 +246,11 @@ def allTests(communicator):
initData.properties = communicator.getProperties().clone()
initData.properties.setProperty("Ice.Override.CloseTimeout", "100")
comm = Ice.initialize(initData)
- connection = comm.stringToProxy(sref).ice_getConnection();
- timeout.holdAdapter(800);
- now = time.clock();
- comm.destroy();
- test((time.clock() - now) < 0.7);
+ connection = comm.stringToProxy(sref).ice_getConnection()
+ timeout.holdAdapter(800)
+ now = time.clock()
+ comm.destroy()
+ test((time.clock() - now) < 0.7)
print("ok")