diff --git a/.github/actions/setup-dependencies/action.yml b/.github/actions/setup-dependencies/action.yml index b68cb04eb1c..1b2ef45e12c 100644 --- a/.github/actions/setup-dependencies/action.yml +++ b/.github/actions/setup-dependencies/action.yml @@ -5,7 +5,10 @@ runs: steps: # Python3 is already installed though Homebrew - name: Install brew dependencies - run: brew install --force --overwrite python ruby openjdk node php lmdb mcpp + run: | + brew unlink python3 + brew link --overwrite python3 + brew install ruby openjdk node php lmdb mcpp shell: bash if: runner.os == 'macOS' diff --git a/cpp/src/Slice/PythonUtil.cpp b/cpp/src/Slice/PythonUtil.cpp index 4a00cf1105b..209bbb51acd 100644 --- a/cpp/src/Slice/PythonUtil.cpp +++ b/cpp/src/Slice/PythonUtil.cpp @@ -817,30 +817,6 @@ Slice::Python::CodeVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p) } _out << "), " << contextParamName << "))"; _out.dec(); - - _out << sp; - writeDocstring(*oli, DocAsyncBegin); - _out << nl << "def begin_" << (*oli)->name() << "(self"; - if(!inParams.empty()) - { - _out << ", " << inParams; - } - _out << ", _response=None, _ex=None, _sent=None, " << contextParamName << "=None):"; - _out.inc(); - _out << nl << "return _M_" << classAbs << "._op_" << (*oli)->name() << ".begin(self, ((" << inParams; - if(!inParams.empty() && inParams.find(',') == string::npos) - { - _out << ", "; - } - _out << "), _response, _ex, _sent, " << contextParamName << "))"; - _out.dec(); - - _out << sp; - writeDocstring(*oli, DocAsyncEnd); - _out << nl << "def end_" << (*oli)->name() << "(self, _r):"; - _out.inc(); - _out << nl << "return _M_" << classAbs << "._op_" << (*oli)->name() << ".end(self, _r)"; - _out.dec(); } _out << sp << nl << "@staticmethod"; @@ -1961,7 +1937,7 @@ Slice::Python::CodeVisitor::writeConstantValue(const TypePtr& type, const Syntax { const string controlChars = "\a\b\f\n\r\t\v"; const unsigned char cutOff = 0; - + _out << "\"" << toStringLiteral(value, controlChars, "", UCN, cutOff) << "\""; break; } diff --git a/python/modules/IcePy/Communicator.cpp b/python/modules/IcePy/Communicator.cpp index 3538a990232..f092378f24d 100644 --- a/python/modules/IcePy/Communicator.cpp +++ b/python/modules/IcePy/Communicator.cpp @@ -823,114 +823,6 @@ communicatorFlushBatchRequestsAsync(CommunicatorObject* self, PyObject* args, Py return future.release(); } -#ifdef WIN32 -extern "C" -#endif -static PyObject* -communicatorBeginFlushBatchRequests(CommunicatorObject* self, PyObject* args, PyObject* kwds) -{ - assert(self->communicator); - - static char* argNames[] = - { - const_cast("compress"), - const_cast("_ex"), - const_cast("_sent"), - 0 - }; - PyObject* compressBatch; - PyObject* ex = Py_None; - PyObject* sent = Py_None; - if(!PyArg_ParseTupleAndKeywords(args, kwds, STRCAST("O|OO"), argNames, &compressBatch, &ex, &sent)) - { - return 0; - } - - PyObject* compressBatchType = lookupType("Ice.CompressBatch"); - if(!PyObject_IsInstance(compressBatch, reinterpret_cast(compressBatchType))) - { - PyErr_Format(PyExc_ValueError, STRCAST("expected an Ice.CompressBatch enumerator")); - return 0; - } - - PyObjectHandle v = getAttr(compressBatch, "_value", false); - assert(v.get()); - Ice::CompressBatch cb = static_cast(PyLong_AsLong(v.get())); - - 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_Communicator_flushBatchRequestsPtr callback; - if(ex || sent) - { - FlushCallbackPtr d = new FlushCallback(ex, sent, "flushBatchRequests"); - callback = Ice::newCallback_Communicator_flushBatchRequests(d, &FlushCallback::exception, &FlushCallback::sent); - } - - Ice::AsyncResultPtr result; - try - { - if(callback) - { - result = (*self->communicator)->begin_flushBatchRequests(cb, callback); - } - else - { - result = (*self->communicator)->begin_flushBatchRequests(cb); - } - } - catch(const Ice::Exception& e) - { - setPythonException(e); - return 0; - } - - return createAsyncResult(result, 0, 0, self->wrapper); -} - -#ifdef WIN32 -extern "C" -#endif -static PyObject* -communicatorEndFlushBatchRequests(CommunicatorObject* self, PyObject* args) -{ - assert(self->communicator); - - 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->communicator)->end_flushBatchRequests(r); - } - catch(const Ice::Exception& ex) - { - setPythonException(ex); - return 0; - } - - Py_INCREF(Py_None); - return Py_None; -} - #ifdef WIN32 extern "C" #endif @@ -1645,11 +1537,6 @@ static PyMethodDef CommunicatorMethods[] = PyDoc_STR(STRCAST("flushBatchRequests(compress) -> None")) }, { STRCAST("flushBatchRequestsAsync"), reinterpret_cast(communicatorFlushBatchRequestsAsync), METH_VARARGS, PyDoc_STR(STRCAST("flushBatchRequestsAsync(compress) -> Ice.Future")) }, - { STRCAST("begin_flushBatchRequests"), reinterpret_cast(communicatorBeginFlushBatchRequests), - METH_VARARGS | METH_KEYWORDS, - PyDoc_STR(STRCAST("begin_flushBatchRequests(compress[, _ex][, _sent]) -> Ice.AsyncResult")) }, - { STRCAST("end_flushBatchRequests"), reinterpret_cast(communicatorEndFlushBatchRequests), - METH_VARARGS, PyDoc_STR(STRCAST("end_flushBatchRequests(Ice.AsyncResult) -> None")) }, { STRCAST("createAdmin"), reinterpret_cast(communicatorCreateAdmin), METH_VARARGS, PyDoc_STR(STRCAST("createAdmin(adminAdapter, adminIdentity) -> Ice.ObjectPrx")) }, { STRCAST("getAdmin"), reinterpret_cast(communicatorGetAdmin), METH_NOARGS, diff --git a/python/modules/IcePy/Connection.cpp b/python/modules/IcePy/Connection.cpp index a6b9a670b8f..9a2cb5d4c9e 100644 --- a/python/modules/IcePy/Connection.cpp +++ b/python/modules/IcePy/Connection.cpp @@ -551,115 +551,6 @@ connectionFlushBatchRequestsAsync(ConnectionObject* self, PyObject* args) return future.release(); } -#ifdef WIN32 -extern "C" -#endif -static PyObject* -connectionBeginFlushBatchRequests(ConnectionObject* self, PyObject* args, PyObject* kwds) -{ - assert(self->connection); - - static char* argNames[] = - { - const_cast("compress"), - const_cast("_ex"), - const_cast("_sent"), - 0 - }; - PyObject* compressBatch; - PyObject* ex = Py_None; - PyObject* sent = Py_None; - if(!PyArg_ParseTupleAndKeywords(args, kwds, STRCAST("O|OO"), argNames, &compressBatch, &ex, &sent)) - { - return 0; - } - - PyObject* compressBatchType = lookupType("Ice.CompressBatch"); - if(!PyObject_IsInstance(compressBatch, reinterpret_cast(compressBatchType))) - { - PyErr_Format(PyExc_ValueError, STRCAST("expected an Ice.CompressBatch enumerator")); - return 0; - } - - PyObjectHandle v = getAttr(compressBatch, "_value", true); - assert(v.get()); - Ice::CompressBatch cb = static_cast(PyLong_AsLong(v.get())); - - 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_flushBatchRequestsPtr callback; - if(ex || sent) - { - FlushCallbackPtr d = new FlushCallback(ex, sent, "flushBatchRequests"); - callback = Ice::newCallback_Connection_flushBatchRequests(d, &FlushCallback::exception, &FlushCallback::sent); - } - - Ice::AsyncResultPtr result; - try - { - if(callback) - { - result = (*self->connection)->begin_flushBatchRequests(cb, callback); - } - else - { - result = (*self->connection)->begin_flushBatchRequests(cb); - } - } - catch(const Ice::Exception& e) - { - setPythonException(e); - return 0; - } - - PyObjectHandle communicator = getCommunicatorWrapper(*self->communicator); - return createAsyncResult(result, 0, reinterpret_cast(self), communicator.get()); -} - -#ifdef WIN32 -extern "C" -#endif -static PyObject* -connectionEndFlushBatchRequests(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 @@ -766,103 +657,6 @@ connectionHeartbeat(ConnectionObject* self, PyObject* /*args*/) 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("_ex"), - const_cast("_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 - { - if(cb) - { - result = (*self->connection)->begin_heartbeat(cb); - } - else - { - result = (*self->connection)->begin_heartbeat(); - } - } - catch(const Ice::Exception& e) - { - setPythonException(e); - return 0; - } - - PyObjectHandle communicator = getCommunicatorWrapper(*self->communicator); - return createAsyncResult(result, 0, reinterpret_cast(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 @@ -1175,20 +969,12 @@ static PyMethodDef ConnectionMethods[] = PyDoc_STR(STRCAST("flushBatchRequests(Ice.CompressBatch) -> None")) }, { STRCAST("flushBatchRequestsAsync"), reinterpret_cast(connectionFlushBatchRequestsAsync), METH_VARARGS, PyDoc_STR(STRCAST("flushBatchRequestsAsync(Ice.CompressBatch) -> Ice.Future")) }, - { STRCAST("begin_flushBatchRequests"), reinterpret_cast(connectionBeginFlushBatchRequests), - METH_VARARGS | METH_KEYWORDS, PyDoc_STR(STRCAST("begin_flushBatchRequests(Ice.CompressBatch, [_ex][, _sent]) -> Ice.AsyncResult")) }, - { STRCAST("end_flushBatchRequests"), reinterpret_cast(connectionEndFlushBatchRequests), METH_VARARGS, - PyDoc_STR(STRCAST("end_flushBatchRequests(Ice.AsyncResult) -> None")) }, { STRCAST("setCloseCallback"), reinterpret_cast(connectionSetCloseCallback), METH_VARARGS, PyDoc_STR(STRCAST("setCloseCallback(Ice.CloseCallback) -> None")) }, { STRCAST("setHeartbeatCallback"), reinterpret_cast(connectionSetHeartbeatCallback), METH_VARARGS, PyDoc_STR(STRCAST("setHeartbeatCallback(Ice.HeartbeatCallback) -> None")) }, { STRCAST("heartbeat"), reinterpret_cast(connectionHeartbeat), METH_NOARGS, PyDoc_STR(STRCAST("heartbeat() -> None")) }, - { STRCAST("begin_heartbeat"), reinterpret_cast(connectionBeginHeartbeat), - METH_VARARGS | METH_KEYWORDS, PyDoc_STR(STRCAST("begin_heartbeat([_ex][, _sent]) -> Ice.AsyncResult")) }, - { STRCAST("end_heartbeat"), reinterpret_cast(connectionEndHeartbeat), METH_VARARGS, - PyDoc_STR(STRCAST("end_heartbeat(Ice.AsyncResult) -> None")) }, { STRCAST("setACM"), reinterpret_cast(connectionSetACM), METH_VARARGS, PyDoc_STR(STRCAST("setACM(int, Ice.ACMClose, Ice.ACMHeartbeat) -> None")) }, { STRCAST("getACM"), reinterpret_cast(connectionGetACM), METH_NOARGS, diff --git a/python/modules/IcePy/Operation.cpp b/python/modules/IcePy/Operation.cpp index 9c1b05c3047..5b63c2cabd2 100644 --- a/python/modules/IcePy/Operation.cpp +++ b/python/modules/IcePy/Operation.cpp @@ -103,7 +103,7 @@ class Invocation : public virtual IceUtil::Shared // Helpers for typed invocations. // - enum MappingType { SyncMapping, AsyncMapping, NewAsyncMapping }; + enum MappingType { SyncMapping, NewAsyncMapping }; // TODO: rename enumerators bool prepareRequest(const OperationPtr&, PyObject*, MappingType, Ice::OutputStream*, pair&); @@ -133,41 +133,10 @@ class SyncTypedInvocation : public Invocation OperationPtr _op; }; -// -// Asynchronous typed invocation. -// -class AsyncTypedInvocation : public Invocation -{ -public: - - AsyncTypedInvocation(const Ice::ObjectPrx&, PyObject*, const OperationPtr&); - ~AsyncTypedInvocation(); - - virtual PyObject* invoke(PyObject*, PyObject* = 0); - PyObject* end(const Ice::ObjectPrx&, const OperationPtr&, const Ice::AsyncResultPtr&); - - string opName() const; - - void response(bool, const pair&); - void exception(const Ice::Exception&); - void sent(bool); - -private: - - void checkAsyncTwowayOnly(const Ice::ObjectPrx&) const; - - OperationPtr _op; - PyObject* _pyProxy; - PyObject* _response; - PyObject* _ex; - PyObject* _sent; -}; -typedef IceUtil::Handle AsyncTypedInvocationPtr; - // // Asynchronous invocation with futures. // -class NewAsyncInvocation : public Invocation +class NewAsyncInvocation : public Invocation // TODO: rename class { public: @@ -229,37 +198,10 @@ class SyncBlobjectInvocation : public Invocation virtual PyObject* invoke(PyObject*, PyObject* = 0); }; -// -// Asynchronous blobject invocation. -// -class AsyncBlobjectInvocation : public Invocation -{ -public: - - AsyncBlobjectInvocation(const Ice::ObjectPrx&, PyObject*); - ~AsyncBlobjectInvocation(); - - virtual PyObject* invoke(PyObject*, PyObject* = 0); - PyObject* end(const Ice::ObjectPrx&, const Ice::AsyncResultPtr&); - - void response(bool, const pair&); - void exception(const Ice::Exception&); - void sent(bool); - -protected: - - PyObject* _pyProxy; - string _op; - PyObject* _response; - PyObject* _ex; - PyObject* _sent; -}; -typedef IceUtil::Handle AsyncBlobjectInvocationPtr; - // // New-style asynchronous blobject invocation. // -class NewAsyncBlobjectInvocation : public NewAsyncInvocation +class NewAsyncBlobjectInvocation : public NewAsyncInvocation // TODO: rename class { public: @@ -585,50 +527,6 @@ operationInvokeAsync(OperationObject* self, PyObject* args) return i->invoke(opArgs); } -#ifdef WIN32 -extern "C" -#endif -static PyObject* -operationBegin(OperationObject* self, PyObject* args) -{ - PyObject* proxy; - PyObject* opArgs; - if(!PyArg_ParseTuple(args, STRCAST("O!O!"), &ProxyType, &proxy, &PyTuple_Type, &opArgs)) - { - return 0; - } - - Ice::ObjectPrx p = getProxy(proxy); - InvocationPtr i = new AsyncTypedInvocation(p, proxy, *self->op); - return i->invoke(opArgs); -} - -#ifdef WIN32 -extern "C" -#endif -static PyObject* -operationEnd(OperationObject* self, PyObject* args) -{ - PyObject* proxy; - PyObject* result; - if(!PyArg_ParseTuple(args, STRCAST("O!O!"), &ProxyType, &proxy, &AsyncResultType, &result)) - { - return 0; - } - - AsyncResultObject* ar = reinterpret_cast(result); - assert(ar); - AsyncTypedInvocationPtr i = AsyncTypedInvocationPtr::dynamicCast(*ar->invocation); - if(!i) - { - PyErr_Format(PyExc_ValueError, STRCAST("invalid AsyncResult object passed to end_%s"), - (*self->op)->name.c_str()); - return 0; - } - Ice::ObjectPrx p = getProxy(proxy); - return i->end(p, *self->op, *ar->result); -} - #ifdef WIN32 extern "C" #endif @@ -903,170 +801,6 @@ asyncResultGetProxy(AsyncResultObject* self, PyObject* /*args*/) return incRef(Py_None); } -#ifdef WIN32 -extern "C" -#endif -static PyObject* -asyncResultIsCompleted(AsyncResultObject* self, PyObject* /*args*/) -{ - bool b = false; - - try - { - assert(self->result); - b = (*self->result)->isCompleted(); - } - catch(...) - { - assert(false); - } - - PyRETURN_BOOL(b); -} - -#ifdef WIN32 -extern "C" -#endif -static PyObject* -asyncResultWaitForCompleted(AsyncResultObject* self, PyObject* /*args*/) -{ - AllowThreads allowThreads; // Release Python's global interpreter lock during remote invocations. - try - { - assert(self->result); - (*self->result)->waitForCompleted(); - } - catch(...) - { - assert(false); - } - - return incRef(Py_None); -} - -#ifdef WIN32 -extern "C" -#endif -static PyObject* -asyncResultIsSent(AsyncResultObject* self, PyObject* /*args*/) -{ - bool b = false; - - try - { - assert(self->result); - b = (*self->result)->isSent(); - } - catch(...) - { - assert(false); - } - - PyRETURN_BOOL(b); -} - -#ifdef WIN32 -extern "C" -#endif -static PyObject* -asyncResultWaitForSent(AsyncResultObject* self, PyObject* /*args*/) -{ - AllowThreads allowThreads; // Release Python's global interpreter lock during remote invocations. - try - { - assert(self->result); - (*self->result)->waitForSent(); - } - catch(...) - { - assert(false); - } - - return incRef(Py_None); -} - -#ifdef WIN32 -extern "C" -#endif -static PyObject* -asyncResultThrowLocalException(AsyncResultObject* self, PyObject* /*args*/) -{ - try - { - assert(self->result); - (*self->result)->throwLocalException(); - } - catch(const Ice::LocalException& ex) - { - setPythonException(ex); - return 0; - } - catch(...) - { - assert(false); - } - - return incRef(Py_None); -} - -#ifdef WIN32 -extern "C" -#endif -static PyObject* -asyncResultSentSynchronously(AsyncResultObject* self, PyObject* /*args*/) -{ - bool b = false; - - try - { - assert(self->result); - b = (*self->result)->sentSynchronously(); - } - catch(...) - { - assert(false); - } - - PyRETURN_BOOL(b); -} - -#ifdef WIN32 -extern "C" -#endif -static PyObject* -asyncResultGetOperation(AsyncResultObject* self, PyObject* /*args*/) -{ - string op; - - try - { - // - // Since the extension uses the Blobject API, calling (*self->result)->getOperation() - // always returns "ice_invoke" as the operation name. If the caller used a regular - // (typed) proxy method, we obtain the actual operation name from the invocation. - // - if(self->invocation) - { - AsyncTypedInvocationPtr i = AsyncTypedInvocationPtr::dynamicCast(*self->invocation); - if(i) - { - op = i->opName(); - } - } - if(op.empty()) - { - assert(self->result); - op = (*self->result)->getOperation(); - } - } - catch(...) - { - assert(false); - } - - return createString(op); -} - #ifdef WIN32 extern "C" #endif @@ -1553,10 +1287,6 @@ static PyMethodDef OperationMethods[] = PyDoc_STR(STRCAST("internal function")) }, { STRCAST("invokeAsync"), reinterpret_cast(operationInvokeAsync), METH_VARARGS, PyDoc_STR(STRCAST("internal function")) }, - { STRCAST("begin"), reinterpret_cast(operationBegin), METH_VARARGS, - PyDoc_STR(STRCAST("internal function")) }, - { STRCAST("end"), reinterpret_cast(operationEnd), METH_VARARGS, - PyDoc_STR(STRCAST("internal function")) }, { STRCAST("deprecate"), reinterpret_cast(operationDeprecate), METH_VARARGS, PyDoc_STR(STRCAST("internal function")) }, { 0, 0 } /* sentinel */ @@ -1588,20 +1318,6 @@ static PyMethodDef AsyncResultMethods[] = PyDoc_STR(STRCAST("returns the connection for the invocation")) }, { STRCAST("getProxy"), reinterpret_cast(asyncResultGetProxy), METH_NOARGS, PyDoc_STR(STRCAST("returns the proxy for the invocation")) }, - { STRCAST("isCompleted"), reinterpret_cast(asyncResultIsCompleted), METH_NOARGS, - PyDoc_STR(STRCAST("returns true if the request is complete")) }, - { STRCAST("waitForCompleted"), reinterpret_cast(asyncResultWaitForCompleted), METH_NOARGS, - PyDoc_STR(STRCAST("blocks until the request is complete")) }, - { STRCAST("isSent"), reinterpret_cast(asyncResultIsSent), METH_NOARGS, - PyDoc_STR(STRCAST("returns true if the request is sent")) }, - { STRCAST("waitForSent"), reinterpret_cast(asyncResultWaitForSent), METH_NOARGS, - PyDoc_STR(STRCAST("blocks until the request is sent")) }, - { STRCAST("throwLocalException"), reinterpret_cast(asyncResultThrowLocalException), METH_NOARGS, - PyDoc_STR(STRCAST("throw location exception if the request failed with a local exception")) }, - { STRCAST("sentSynchronously"), reinterpret_cast(asyncResultSentSynchronously), METH_NOARGS, - PyDoc_STR(STRCAST("returns true if the request was sent synchronously")) }, - { STRCAST("getOperation"), reinterpret_cast(asyncResultGetOperation), METH_NOARGS, - PyDoc_STR(STRCAST("returns the name of the operation")) }, { STRCAST("callLater"), reinterpret_cast(asyncResultCallLater), METH_VARARGS, PyDoc_STR(STRCAST("internal function")) }, { 0, 0 } /* sentinel */ @@ -1930,10 +1646,6 @@ IcePy::Invocation::prepareRequest(const OperationPtr& op, PyObject* args, Mappin { opName = op->name + "Async"; } - else if(mapping == AsyncMapping) - { - opName = "begin_" + op->name; - } else { opName = fixIdent(op->name); @@ -1969,10 +1681,6 @@ IcePy::Invocation::prepareRequest(const OperationPtr& op, PyObject* args, Mappin { name = op->name + "Async"; } - else if(mapping == AsyncMapping) - { - name = "begin_" + op->name; - } else { name = fixIdent(op->name); @@ -2338,420 +2046,89 @@ IcePy::SyncTypedInvocation::invoke(PyObject* args, PyObject* /* kwds */) } // -// AsyncTypedInvocation +// NewAsyncInvocation // -IcePy::AsyncTypedInvocation::AsyncTypedInvocation(const Ice::ObjectPrx& prx, PyObject* pyProxy, - const OperationPtr& op) : - Invocation(prx), _op(op), _pyProxy(pyProxy), _response(0), _ex(0), _sent(0) +IcePy::NewAsyncInvocation::NewAsyncInvocation(const Ice::ObjectPrx& prx, PyObject* pyProxy, const string& operation) + : Invocation(prx), _pyProxy(pyProxy), _operation(operation), _twoway(prx->ice_isTwoway()), _sent(false), + _sentSynchronously(false), _done(false), _future(0), _ok(false), _exception(0) { Py_INCREF(_pyProxy); } -IcePy::AsyncTypedInvocation::~AsyncTypedInvocation() +IcePy::NewAsyncInvocation::~NewAsyncInvocation() { AdoptThread adoptThread; // Ensure the current thread is able to call into Python. Py_DECREF(_pyProxy); - Py_XDECREF(_response); - Py_XDECREF(_ex); - Py_XDECREF(_sent); + Py_XDECREF(_future); + Py_XDECREF(_exception); } PyObject* -IcePy::AsyncTypedInvocation::invoke(PyObject* args, PyObject* /* kwds */) +IcePy::NewAsyncInvocation::invoke(PyObject* args, PyObject* kwds) { - assert(PyTuple_Check(args)); - assert(PyTuple_GET_SIZE(args) == 5); // Format is ((params...), response|None, exception|None, sent|None, ctx|None) - PyObject* pyparams = PyTuple_GET_ITEM(args, 0); - assert(PyTuple_Check(pyparams)); + // + // Called from Python code, so the GIL is already acquired. + // - PyObject* callable; + Ice::AsyncResultPtr result; - callable = PyTuple_GET_ITEM(args, 1); - if(PyCallable_Check(callable)) + try { - _response = incRef(callable); + result = handleInvoke(args, kwds); } - else if(callable != Py_None) + catch(const Ice::CommunicatorDestroyedException& ex) { - PyErr_Format(PyExc_RuntimeError, STRCAST("response callback must be a callable object or None")); + // + // CommunicatorDestroyedException can propagate directly. + // + setPythonException(ex); return 0; } - - callable = PyTuple_GET_ITEM(args, 2); - if(PyCallable_Check(callable)) - { - _ex = incRef(callable); - } - else if(callable != Py_None) + catch(const Ice::TwowayOnlyException& ex) { - PyErr_Format(PyExc_RuntimeError, STRCAST("exception callback must be a callable object or None")); + // + // TwowayOnlyException can propagate directly. + // + setPythonException(ex); return 0; } - - callable = PyTuple_GET_ITEM(args, 3); - if(PyCallable_Check(callable)) + catch(const Ice::Exception&) { - _sent = incRef(callable); + // + // No other exceptions should be raised by invoke. + // + assert(false); } - else if(callable != Py_None) + + if(PyErr_Occurred()) { - PyErr_Format(PyExc_RuntimeError, STRCAST("sent callback must be a callable object or None")); return 0; } - if(!_ex && (_response || _sent)) + assert(result); + + // + // NOTE: Any time we call into interpreted Python code there's a chance that another thread will be + // allowed to run! + // + + PyObjectHandle communicatorObj = getCommunicatorWrapper(_communicator); + + PyObjectHandle asyncResultObj = createAsyncResult(result, _pyProxy, 0, communicatorObj.get()); + if(!asyncResultObj.get()) { - PyErr_Format(PyExc_RuntimeError, - STRCAST("exception callback must also be provided when response or sent callbacks are used")); return 0; } - PyObject* pyctx = PyTuple_GET_ITEM(args, 4); - if(pyctx != Py_None && !PyDict_Check(pyctx)) + PyObjectHandle future = createFuture(_operation, asyncResultObj.get()); // Calls into Python code. + if(!future.get()) { - PyErr_Format(PyExc_RuntimeError, STRCAST("context must be a dictionary or None")); return 0; } // - // Marshal the input parameters to a byte sequence. - // - Ice::OutputStream os(_communicator); - pair params; - if(!prepareRequest(_op, pyparams, AsyncMapping, &os, params)) - { - return 0; - } - - Ice::AsyncResultPtr result; - try - { - checkAsyncTwowayOnly(_prx); - - Ice::Callback_Object_ice_invokePtr cb; - if(_response || _ex || _sent) - { - cb = Ice::newCallback_Object_ice_invoke(this, &AsyncTypedInvocation::response, - &AsyncTypedInvocation::exception, &AsyncTypedInvocation::sent); - } - - // - // Invoke the operation asynchronously. - // - if(pyctx != Py_None) - { - Ice::Context ctx; - if(!dictionaryToContext(pyctx, ctx)) - { - return 0; - } - - if(cb) - { - result = _prx->begin_ice_invoke(_op->name, _op->sendMode, params, ctx, cb); - } - else - { - result = _prx->begin_ice_invoke(_op->name, _op->sendMode, params, ctx); - } - } - else - { - if(cb) - { - result = _prx->begin_ice_invoke(_op->name, _op->sendMode, params, cb); - } - else - { - result = _prx->begin_ice_invoke(_op->name, _op->sendMode, params); - } - } - } - catch(const Ice::CommunicatorDestroyedException& ex) - { - // - // CommunicatorDestroyedException can propagate directly. - // - setPythonException(ex); - return 0; - } - catch(const IceUtil::IllegalArgumentException& ex) - { - // - // IllegalArgumentException can propagate directly. - // (Raised by checkAsyncTwowayOnly) - // - PyErr_Format(PyExc_RuntimeError, "%s", STRCAST(ex.reason().c_str())); - return 0; - } - catch(const Ice::Exception&) - { - // - // No other exceptions should be raised by begin_ice_invoke. - // - assert(false); - } - - assert(result); - AsyncResultObject* obj = asyncResultNew(&AsyncResultType, 0, 0); - if(!obj) - { - return 0; - } - obj->result = new Ice::AsyncResultPtr(result); - obj->invocation = new InvocationPtr(this); - obj->proxy = incRef(_pyProxy); - obj->communicator = getCommunicatorWrapper(_communicator); - return reinterpret_cast(obj); -} - -PyObject* -IcePy::AsyncTypedInvocation::end(const Ice::ObjectPrx& proxy, const OperationPtr& op, const Ice::AsyncResultPtr& r) -{ - try - { - if(op.get() != _op.get()) - { - throw IceUtil::IllegalArgumentException(__FILE__, __LINE__, "end_" + op->name + - " called with AsyncResult object from begin_" + _op->name); - } - - pair results; - bool ok; - - { - AllowThreads allowThreads; // Release Python's global interpreter lock during blocking operations. - ok = proxy->_iceI_end_ice_invoke(results, r); - } - - if(ok) - { - // - // Unmarshal the results. - // - PyObjectHandle args = unmarshalResults(_op, results); - if(args.get()) - { - // - // If there are no results, return None. If there's only one element - // in the tuple, return the element. Otherwise, return the tuple. - // - assert(PyTuple_Check(args.get())); - if(PyTuple_GET_SIZE(args.get()) == 0) - { - return incRef(Py_None); - } - else if(PyTuple_GET_SIZE(args.get()) == 1) - { - PyObject* res = PyTuple_GET_ITEM(args.get(), 0); - return incRef(res); - } - else - { - return args.release(); - } - } - } - else - { - PyObjectHandle ex = unmarshalException(_op, results); - setPythonException(ex.get()); - } - } - catch(const AbortMarshaling&) - { - // Nothing to do. - } - catch(const IceUtil::IllegalArgumentException& ex) - { - PyErr_Format(PyExc_RuntimeError, "%s", STRCAST(ex.reason().c_str())); - } - catch(const Ice::Exception& ex) - { - setPythonException(ex); - } - - assert(PyErr_Occurred()); - return 0; -} - -string -IcePy::AsyncTypedInvocation::opName() const -{ - return _op->name; -} - -void -IcePy::AsyncTypedInvocation::response(bool ok, const pair& results) -{ - AdoptThread adoptThread; // Ensure the current thread is able to call into Python. - - try - { - if(ok) - { - if(_response) - { - // - // Unmarshal the results. - // - PyObjectHandle args; - try - { - args = unmarshalResults(_op, results); - if(!args.get()) - { - assert(PyErr_Occurred()); - PyErr_Print(); - return; - } - } - catch(const Ice::Exception& ex) - { - assert(_ex); - callException(_ex, ex); - return; - } - - PyObjectHandle tmp = PyObject_Call(_response, args.get(), 0); - if(PyErr_Occurred()) - { - handleException(); // Callback raised an exception. - } - } - } - else - { - assert(_ex); - PyObjectHandle ex = unmarshalException(_op, results); - callException(_ex, ex.get()); - } - } - catch(const AbortMarshaling&) - { - assert(PyErr_Occurred()); - PyErr_Print(); - } -} - -void -IcePy::AsyncTypedInvocation::exception(const Ice::Exception& ex) -{ - AdoptThread adoptThread; // Ensure the current thread is able to call into Python. - assert(_ex); - callException(_ex, ex); -} - -void -IcePy::AsyncTypedInvocation::sent(bool sentSynchronously) -{ - if(_sent) - { - AdoptThread adoptThread; // Ensure the current thread is able to call into Python. - callSent(_sent, sentSynchronously, true); - } -} - -void -IcePy::AsyncTypedInvocation::checkAsyncTwowayOnly(const Ice::ObjectPrx& proxy) const -{ - if((_op->returnType != 0 || !_op->outParams.empty() || !_op->exceptions.empty()) && !proxy->ice_isTwoway()) - { - throw IceUtil::IllegalArgumentException(__FILE__, __LINE__, - "`" + _op->name + "' can only be called with a twoway proxy"); - } - - if((_op->returnType != 0 || !_op->outParams.empty()) && (!_response && (_ex || _sent))) - { - throw IceUtil::IllegalArgumentException(__FILE__, __LINE__, "`" + _op->name + "' requires a response callback"); - } -} - -// -// NewAsyncInvocation -// -IcePy::NewAsyncInvocation::NewAsyncInvocation(const Ice::ObjectPrx& prx, PyObject* pyProxy, const string& operation) - : Invocation(prx), _pyProxy(pyProxy), _operation(operation), _twoway(prx->ice_isTwoway()), _sent(false), - _sentSynchronously(false), _done(false), _future(0), _ok(false), _exception(0) -{ - Py_INCREF(_pyProxy); -} - -IcePy::NewAsyncInvocation::~NewAsyncInvocation() -{ - AdoptThread adoptThread; // Ensure the current thread is able to call into Python. - - Py_DECREF(_pyProxy); - Py_XDECREF(_future); - Py_XDECREF(_exception); -} - -PyObject* -IcePy::NewAsyncInvocation::invoke(PyObject* args, PyObject* kwds) -{ - // - // Called from Python code, so the GIL is already acquired. - // - - Ice::AsyncResultPtr result; - - try - { - result = handleInvoke(args, kwds); - } - catch(const Ice::CommunicatorDestroyedException& ex) - { - // - // CommunicatorDestroyedException can propagate directly. - // - setPythonException(ex); - return 0; - } - catch(const Ice::TwowayOnlyException& ex) - { - // - // TwowayOnlyException can propagate directly. - // - setPythonException(ex); - return 0; - } - catch(const Ice::Exception&) - { - // - // No other exceptions should be raised by begin_ice_invoke. - // - assert(false); - } - - if(PyErr_Occurred()) - { - return 0; - } - - assert(result); - - // - // NOTE: Any time we call into interpreted Python code there's a chance that another thread will be - // allowed to run! - // - - PyObjectHandle communicatorObj = getCommunicatorWrapper(_communicator); - - PyObjectHandle asyncResultObj = createAsyncResult(result, _pyProxy, 0, communicatorObj.get()); - if(!asyncResultObj.get()) - { - return 0; - } - - PyObjectHandle future = createFuture(_operation, asyncResultObj.get()); // Calls into Python code. - if(!future.get()) - { - return 0; - } - - // - // Check if any callbacks have been invoked already. + // Check if any callbacks have been invoked already. // if(!_prx->ice_isBatchOneway() && !_prx->ice_isBatchDatagram()) { @@ -3059,225 +2436,62 @@ IcePy::NewAsyncTypedInvocation::handleResponse(PyObject* future, bool ok, // - If the operation returns one value, the result is the value // - If the operation returns multiple values, the result is a tuple containing the values // - PyObjectHandle r; - if(PyTuple_GET_SIZE(args.get()) == 0) - { - r = incRef(Py_None); - } - else if(PyTuple_GET_SIZE(args.get()) == 1) - { - r = incRef(PyTuple_GET_ITEM(args.get(), 0)); // PyTuple_GET_ITEM steals a reference. - } - else - { - r = args; - } - - PyObjectHandle tmp = callMethod(future, "set_result", r.get()); - PyErr_Clear(); - } - else - { - PyObjectHandle ex = unmarshalException(_op, results); - PyObjectHandle tmp = callMethod(future, "set_exception", ex.get()); - PyErr_Clear(); - } - } - catch(const AbortMarshaling&) - { - assert(PyErr_Occurred()); - } -} - -// -// SyncBlobjectInvocation -// -IcePy::SyncBlobjectInvocation::SyncBlobjectInvocation(const Ice::ObjectPrx& prx) - : Invocation(prx) -{ -} - -PyObject* -IcePy::SyncBlobjectInvocation::invoke(PyObject* args, PyObject* /* kwds */) -{ - char* operation; - PyObject* mode; - PyObject* inParams; - PyObject* operationModeType = lookupType("Ice.OperationMode"); - PyObject* ctx = 0; - if(!PyArg_ParseTuple(args, STRCAST("sO!O!|O"), &operation, operationModeType, &mode, &PyBytes_Type, &inParams, - &ctx)) - { - return 0; - } - - PyObjectHandle modeValue = getAttr(mode, "value", true); - Ice::OperationMode sendMode = (Ice::OperationMode)static_cast(PyLong_AsLong(modeValue.get())); - assert(!PyErr_Occurred()); - - Py_ssize_t sz = PyBytes_GET_SIZE(inParams); - pair in(static_cast(0), - static_cast(0)); - if(sz > 0) - { - in.first = reinterpret_cast(PyBytes_AS_STRING(inParams)); - in.second = in.first + sz; - } - - try - { - vector out; - - bool ok; - if(ctx == 0 || ctx == Py_None) - { - AllowThreads allowThreads; // Release Python's global interpreter lock during remote invocations. - ok = _prx->ice_invoke(operation, sendMode, in, out); - } - else - { - Ice::Context context; - if(!dictionaryToContext(ctx, context)) - { - return 0; - } - - AllowThreads allowThreads; // Release Python's global interpreter lock during remote invocations. - ok = _prx->ice_invoke(operation, sendMode, in, out, context); - } - - // - // Prepare the result as a tuple of the bool and out param buffer. - // - PyObjectHandle result = PyTuple_New(2); - if(!result.get()) - { - throwPythonException(); - } - - PyTuple_SET_ITEM(result.get(), 0, ok ? incTrue() : incFalse()); + PyObjectHandle r; + if(PyTuple_GET_SIZE(args.get()) == 0) + { + r = incRef(Py_None); + } + else if(PyTuple_GET_SIZE(args.get()) == 1) + { + r = incRef(PyTuple_GET_ITEM(args.get(), 0)); // PyTuple_GET_ITEM steals a reference. + } + else + { + r = args; + } - PyObjectHandle op; - if(out.empty()) - { - op = PyBytes_FromString(""); + PyObjectHandle tmp = callMethod(future, "set_result", r.get()); + PyErr_Clear(); } else { - op = PyBytes_FromStringAndSize(reinterpret_cast(&out[0]), static_cast(out.size())); - } - if(!op.get()) - { - throwPythonException(); + PyObjectHandle ex = unmarshalException(_op, results); + PyObjectHandle tmp = callMethod(future, "set_exception", ex.get()); + PyErr_Clear(); } - - PyTuple_SET_ITEM(result.get(), 1, op.release()); // PyTuple_SET_ITEM steals a reference. - - return result.release(); } - catch(const Ice::Exception& ex) + catch(const AbortMarshaling&) { - setPythonException(ex); - return 0; + assert(PyErr_Occurred()); } } // -// AsyncBlobjectInvocation +// SyncBlobjectInvocation // -IcePy::AsyncBlobjectInvocation::AsyncBlobjectInvocation(const Ice::ObjectPrx& prx, PyObject* pyProxy) : - Invocation(prx), _pyProxy(pyProxy), _response(0), _ex(0), _sent(0) -{ - Py_INCREF(_pyProxy); -} - -IcePy::AsyncBlobjectInvocation::~AsyncBlobjectInvocation() +IcePy::SyncBlobjectInvocation::SyncBlobjectInvocation(const Ice::ObjectPrx& prx) + : Invocation(prx) { - AdoptThread adoptThread; // Ensure the current thread is able to call into Python. - - Py_DECREF(_pyProxy); - Py_XDECREF(_response); - Py_XDECREF(_ex); - Py_XDECREF(_sent); } PyObject* -IcePy::AsyncBlobjectInvocation::invoke(PyObject* args, PyObject* kwds) -{ - static char* argNames[] = - { - const_cast("op"), - const_cast("mode"), - const_cast("inParams"), - const_cast("_response"), - const_cast("_ex"), - const_cast("_sent"), - const_cast("context"), - 0 - }; +IcePy::SyncBlobjectInvocation::invoke(PyObject* args, PyObject* /* kwds */) +{ char* operation; PyObject* mode; PyObject* inParams; PyObject* operationModeType = lookupType("Ice.OperationMode"); - PyObject* response = Py_None; - PyObject* ex = Py_None; - PyObject* sent = Py_None; - PyObject* pyctx = Py_None; - if(!PyArg_ParseTupleAndKeywords(args, kwds, STRCAST("sO!O!|OOOO"), argNames, &operation, operationModeType, &mode, - &PyBytes_Type, &inParams, &response, &ex, &sent, &pyctx)) + PyObject* ctx = 0; + if(!PyArg_ParseTuple(args, STRCAST("sO!O!|O"), &operation, operationModeType, &mode, &PyBytes_Type, &inParams, + &ctx)) { return 0; } - _op = operation; - PyObjectHandle modeValue = getAttr(mode, "value", true); Ice::OperationMode sendMode = (Ice::OperationMode)static_cast(PyLong_AsLong(modeValue.get())); assert(!PyErr_Occurred()); - if(PyCallable_Check(response)) - { - _response = incRef(response); - } - else if(response != Py_None) - { - PyErr_Format(PyExc_RuntimeError, STRCAST("response callback must be a callable object or None")); - return 0; - } - - if(PyCallable_Check(ex)) - { - _ex = incRef(ex); - } - else if(ex != Py_None) - { - PyErr_Format(PyExc_RuntimeError, STRCAST("exception callback must be a callable object or None")); - return 0; - } - - if(PyCallable_Check(sent)) - { - _sent = incRef(sent); - } - else if(sent != Py_None) - { - PyErr_Format(PyExc_RuntimeError, STRCAST("sent callback must be a callable object or None")); - return 0; - } - - if(!_ex && (_response || _sent)) - { - PyErr_Format(PyExc_RuntimeError, - STRCAST("exception callback must also be provided when response or sent callbacks are used")); - return 0; - } - - if(pyctx != Py_None && !PyDict_Check(pyctx)) - { - PyErr_Format(PyExc_RuntimeError, STRCAST("context must be a dictionary or None")); - return 0; - } - Py_ssize_t sz = PyBytes_GET_SIZE(inParams); pair in(static_cast(0), static_cast(0)); @@ -3287,195 +2501,61 @@ IcePy::AsyncBlobjectInvocation::invoke(PyObject* args, PyObject* kwds) in.second = in.first + sz; } - Ice::AsyncResultPtr result; try { - Ice::Callback_Object_ice_invokePtr cb; - if(_response || _ex || _sent) - { - cb = Ice::newCallback_Object_ice_invoke(this, &AsyncBlobjectInvocation::response, - &AsyncBlobjectInvocation::exception, - &AsyncBlobjectInvocation::sent); - } + vector out; - if(pyctx == Py_None) + bool ok; + if(ctx == 0 || ctx == Py_None) { - if(cb) - { - result = _prx->begin_ice_invoke(operation, sendMode, in, cb); - } - else - { - result = _prx->begin_ice_invoke(operation, sendMode, in); - } + AllowThreads allowThreads; // Release Python's global interpreter lock during remote invocations. + ok = _prx->ice_invoke(operation, sendMode, in, out); } else { Ice::Context context; - if(!dictionaryToContext(pyctx, context)) + if(!dictionaryToContext(ctx, context)) { return 0; } - if(cb) - { - result = _prx->begin_ice_invoke(operation, sendMode, in, context, cb); - } - else - { - result = _prx->begin_ice_invoke(operation, sendMode, in, context); - } - } - } - catch(const Ice::CommunicatorDestroyedException& e) - { - // - // CommunicatorDestroyedException is the only exception that can propagate directly. - // - setPythonException(e); - return 0; - } - catch(const Ice::Exception&) - { - // - // No other exceptions should be raised by begin_ice_invoke. - // - assert(false); - } - - assert(result); - AsyncResultObject* obj = asyncResultNew(&AsyncResultType, 0, 0); - if(!obj) - { - return 0; - } - obj->result = new Ice::AsyncResultPtr(result); - obj->invocation = new InvocationPtr(this); - obj->proxy = incRef(_pyProxy); - obj->communicator = getCommunicatorWrapper(_prx->ice_getCommunicator()); - return reinterpret_cast(obj); -} - -PyObject* -IcePy::AsyncBlobjectInvocation::end(const Ice::ObjectPrx& proxy, const Ice::AsyncResultPtr& r) -{ - try - { - pair results; - bool ok; - - { - AllowThreads allowThreads; // Release Python's global interpreter lock during blocking operations. - ok = proxy->_iceI_end_ice_invoke(results, r); + AllowThreads allowThreads; // Release Python's global interpreter lock during remote invocations. + ok = _prx->ice_invoke(operation, sendMode, in, out, context); } // - // Prepare the results as a tuple of the bool and out param buffer. + // Prepare the result as a tuple of the bool and out param buffer. // - PyObjectHandle args = PyTuple_New(2); - if(!args.get()) + PyObjectHandle result = PyTuple_New(2); + if(!result.get()) { - return 0; + throwPythonException(); } - PyTuple_SET_ITEM(args.get(), 0, ok ? incTrue() : incFalse()); + PyTuple_SET_ITEM(result.get(), 0, ok ? incTrue() : incFalse()); - Py_ssize_t sz = results.second - results.first; PyObjectHandle op; - if(sz == 0) + if(out.empty()) { op = PyBytes_FromString(""); } else { - op = PyBytes_FromStringAndSize(reinterpret_cast(results.first), sz); + op = PyBytes_FromStringAndSize(reinterpret_cast(&out[0]), static_cast(out.size())); } if(!op.get()) { - return 0; + throwPythonException(); } - PyTuple_SET_ITEM(args.get(), 1, op.release()); // PyTuple_SET_ITEM steals a reference. - return args.release(); - } - catch(const AbortMarshaling&) - { - // Nothing to do. - } - catch(const IceUtil::IllegalArgumentException& ex) - { - PyErr_Format(PyExc_RuntimeError, "%s", STRCAST(ex.reason().c_str())); + PyTuple_SET_ITEM(result.get(), 1, op.release()); // PyTuple_SET_ITEM steals a reference. + + return result.release(); } catch(const Ice::Exception& ex) { setPythonException(ex); - } - - assert(PyErr_Occurred()); - return 0; -} - -void -IcePy::AsyncBlobjectInvocation::response(bool ok, const pair& results) -{ - if(_response) - { - AdoptThread adoptThread; // Ensure the current thread is able to call into Python. - - // - // Prepare the args as a tuple of the bool and out param buffer. - // - PyObjectHandle args = PyTuple_New(2); - if(!args.get()) - { - assert(PyErr_Occurred()); - PyErr_Print(); - return; - } - - PyTuple_SET_ITEM(args.get(), 0, ok ? incTrue() : incFalse()); - Py_ssize_t sz = results.second - results.first; - PyObjectHandle op; - if(sz == 0) - { - op = PyBytes_FromString(""); - } - else - { - op = PyBytes_FromStringAndSize(reinterpret_cast(results.first), sz); - } - if(!op.get()) - { - assert(PyErr_Occurred()); - PyErr_Print(); - return; - } - - PyTuple_SET_ITEM(args.get(), 1, op.release()); // PyTuple_SET_ITEM steals a reference. - - PyObjectHandle tmp = PyObject_Call(_response, args.get(), 0); - if(PyErr_Occurred()) - { - handleException(); // Callback raised an exception. - } - } -} - -void -IcePy::AsyncBlobjectInvocation::exception(const Ice::Exception& ex) -{ - AdoptThread adoptThread; // Ensure the current thread is able to call into Python. - assert(_ex); - callException(_ex, ex); -} - -void -IcePy::AsyncBlobjectInvocation::sent(bool sentSynchronously) -{ - if(_sent) - { - AdoptThread adoptThread; // Ensure the current thread is able to call into Python. - callSent(_sent, sentSynchronously, true); + return 0; } } @@ -4026,53 +3106,6 @@ IcePy::invokeBuiltinAsync(PyObject* proxy, const string& builtin, PyObject* args return i->invoke(args); } -PyObject* -IcePy::beginBuiltin(PyObject* proxy, const string& builtin, PyObject* args) -{ - string name = "_op_" + builtin; - PyObject* objectType = lookupType("Ice.Object"); - assert(objectType); - PyObjectHandle obj = getAttr(objectType, name, false); - assert(obj.get()); - - OperationPtr op = getOperation(obj.get()); - assert(op); - - Ice::ObjectPrx p = getProxy(proxy); - InvocationPtr i = new AsyncTypedInvocation(p, proxy, op); - return i->invoke(args); -} - -PyObject* -IcePy::endBuiltin(PyObject* proxy, const string& builtin, PyObject* args) -{ - PyObject* result; - if(!PyArg_ParseTuple(args, STRCAST("O!"), &AsyncResultType, &result)) - { - return 0; - } - - string name = "_op_" + builtin; - PyObject* objectType = lookupType("Ice.Object"); - assert(objectType); - PyObjectHandle obj = getAttr(objectType, name, false); - assert(obj.get()); - - OperationPtr op = getOperation(obj.get()); - assert(op); - - AsyncResultObject* ar = reinterpret_cast(result); - assert(ar); - AsyncTypedInvocationPtr i = AsyncTypedInvocationPtr::dynamicCast(*ar->invocation); - if(!i) - { - PyErr_Format(PyExc_ValueError, STRCAST("invalid AsyncResult object passed to end_%s"), op->name.c_str()); - return 0; - } - Ice::ObjectPrx p = getProxy(proxy); - return i->end(p, op, *ar->result); -} - PyObject* IcePy::iceInvoke(PyObject* proxy, PyObject* args) { @@ -4089,35 +3122,6 @@ IcePy::iceInvokeAsync(PyObject* proxy, PyObject* args) return i->invoke(args); } -PyObject* -IcePy::beginIceInvoke(PyObject* proxy, PyObject* args, PyObject* kwds) -{ - Ice::ObjectPrx p = getProxy(proxy); - InvocationPtr i = new AsyncBlobjectInvocation(p, proxy); - return i->invoke(args, kwds); -} - -PyObject* -IcePy::endIceInvoke(PyObject* proxy, PyObject* args) -{ - PyObject* result; - if(!PyArg_ParseTuple(args, STRCAST("O!"), &AsyncResultType, &result)) - { - return 0; - } - - AsyncResultObject* ar = reinterpret_cast(result); - assert(ar); - AsyncBlobjectInvocationPtr i = AsyncBlobjectInvocationPtr::dynamicCast(*ar->invocation); - if(!i) - { - PyErr_Format(PyExc_ValueError, STRCAST("invalid AsyncResult object passed to end_ice_invoke")); - return 0; - } - Ice::ObjectPrx p = getProxy(proxy); - return i->end(p, *ar->result); -} - PyObject* IcePy::createAsyncResult(const Ice::AsyncResultPtr& r, PyObject* proxy, PyObject* connection, PyObject* communicator) { diff --git a/python/modules/IcePy/Operation.h b/python/modules/IcePy/Operation.h index e684a306119..38ccfd7ec59 100644 --- a/python/modules/IcePy/Operation.h +++ b/python/modules/IcePy/Operation.h @@ -23,16 +23,12 @@ bool initOperation(PyObject*); // PyObject* invokeBuiltin(PyObject*, const std::string&, PyObject*); PyObject* invokeBuiltinAsync(PyObject*, const std::string&, PyObject*); -PyObject* beginBuiltin(PyObject*, const std::string&, PyObject*); -PyObject* endBuiltin(PyObject*, const std::string&, PyObject*); // // Blobject invocations. // PyObject* iceInvoke(PyObject*, PyObject*); PyObject* iceInvokeAsync(PyObject*, PyObject*); -PyObject* beginIceInvoke(PyObject*, PyObject*, PyObject*); -PyObject* endIceInvoke(PyObject*, PyObject*); extern PyTypeObject AsyncResultType; PyObject* createAsyncResult(const Ice::AsyncResultPtr&, PyObject*, PyObject*, PyObject*); diff --git a/python/modules/IcePy/Proxy.cpp b/python/modules/IcePy/Proxy.cpp index e268dd9a034..9ba46beec22 100644 --- a/python/modules/IcePy/Proxy.cpp +++ b/python/modules/IcePy/Proxy.cpp @@ -215,50 +215,6 @@ proxyIceIsAAsync(ProxyObject* self, PyObject* args) return invokeBuiltinAsync(reinterpret_cast(self), "ice_isA", newArgs.get()); } -#ifdef WIN32 -extern "C" -#endif -static PyObject* -proxyBeginIceIsA(ProxyObject* self, PyObject* args, PyObject* kwds) -{ - static char* argNames[] = - { - const_cast("type"), - const_cast("_response"), - const_cast("_ex"), - const_cast("_sent"), - const_cast("context"), - 0 - }; - PyObject* type; - PyObject* response = Py_None; - PyObject* ex = Py_None; - PyObject* sent = Py_None; - PyObject* ctx = Py_None; - if(!PyArg_ParseTupleAndKeywords(args, kwds, STRCAST("O|OOOO"), argNames, &type, &response, &ex, &sent, &ctx)) - { - return 0; - } - - // - // We need to reformat the arguments to match what is used by the generated code: - // - // ((params...), response|None, ex|None, sent|None, ctx|None) - // - PyObjectHandle newArgs = Py_BuildValue(STRCAST("((O), O, O, O, O)"), type, response, ex, sent, ctx); - - return beginBuiltin(reinterpret_cast(self), "ice_isA", newArgs.get()); -} - -#ifdef WIN32 -extern "C" -#endif -static PyObject* -proxyEndIceIsA(ProxyObject* self, PyObject* args) -{ - return endBuiltin(reinterpret_cast(self), "ice_isA", args); -} - #ifdef WIN32 extern "C" #endif @@ -299,48 +255,6 @@ proxyIcePingAsync(ProxyObject* self, PyObject* args) return invokeBuiltinAsync(reinterpret_cast(self), "ice_ping", newArgs.get()); } -#ifdef WIN32 -extern "C" -#endif -static PyObject* -proxyBeginIcePing(ProxyObject* self, PyObject* args, PyObject* kwds) -{ - static char* argNames[] = - { - const_cast("_response"), - const_cast("_ex"), - const_cast("_sent"), - const_cast("context"), - 0 - }; - PyObject* response = Py_None; - PyObject* ex = Py_None; - PyObject* sent = Py_None; - PyObject* ctx = Py_None; - if(!PyArg_ParseTupleAndKeywords(args, kwds, STRCAST("|OOOO"), argNames, &response, &ex, &sent, &ctx)) - { - return 0; - } - - // - // We need to reformat the arguments to match what is used by the generated code: - // - // ((params...), response|None, ex|None, sent|None, ctx|None) - // - PyObjectHandle newArgs = Py_BuildValue(STRCAST("((), O, O, O, O)"), response, ex, sent, ctx); - - return beginBuiltin(reinterpret_cast(self), "ice_ping", newArgs.get()); -} - -#ifdef WIN32 -extern "C" -#endif -static PyObject* -proxyEndIcePing(ProxyObject* self, PyObject* args) -{ - return endBuiltin(reinterpret_cast(self), "ice_ping", args); -} - #ifdef WIN32 extern "C" #endif @@ -381,48 +295,6 @@ proxyIceIdsAsync(ProxyObject* self, PyObject* args) return invokeBuiltinAsync(reinterpret_cast(self), "ice_ids", newArgs.get()); } -#ifdef WIN32 -extern "C" -#endif -static PyObject* -proxyBeginIceIds(ProxyObject* self, PyObject* args, PyObject* kwds) -{ - static char* argNames[] = - { - const_cast("_response"), - const_cast("_ex"), - const_cast("_sent"), - const_cast("context"), - 0 - }; - PyObject* response = Py_None; - PyObject* ex = Py_None; - PyObject* sent = Py_None; - PyObject* ctx = Py_None; - if(!PyArg_ParseTupleAndKeywords(args, kwds, STRCAST("|OOOO"), argNames, &response, &ex, &sent, &ctx)) - { - return 0; - } - - // - // We need to reformat the arguments to match what is used by the generated code: - // - // ((params...), response|None, ex|None, sent|None, ctx|None) - // - PyObjectHandle newArgs = Py_BuildValue(STRCAST("((), O, O, O, O)"), response, ex, sent, ctx); - - return beginBuiltin(reinterpret_cast(self), "ice_ids", newArgs.get()); -} - -#ifdef WIN32 -extern "C" -#endif -static PyObject* -proxyEndIceIds(ProxyObject* self, PyObject* args) -{ - return endBuiltin(reinterpret_cast(self), "ice_ids", args); -} - #ifdef WIN32 extern "C" #endif @@ -463,48 +335,6 @@ proxyIceIdAsync(ProxyObject* self, PyObject* args) return invokeBuiltinAsync(reinterpret_cast(self), "ice_id", newArgs.get()); } -#ifdef WIN32 -extern "C" -#endif -static PyObject* -proxyBeginIceId(ProxyObject* self, PyObject* args, PyObject* kwds) -{ - static char* argNames[] = - { - const_cast("_response"), - const_cast("_ex"), - const_cast("_sent"), - const_cast("context"), - 0 - }; - PyObject* response = Py_None; - PyObject* ex = Py_None; - PyObject* sent = Py_None; - PyObject* ctx = Py_None; - if(!PyArg_ParseTupleAndKeywords(args, kwds, STRCAST("|OOOO"), argNames, &response, &ex, &sent, &ctx)) - { - return 0; - } - - // - // We need to reformat the arguments to match what is used by the generated code: - // - // ((params...), response|None, ex|None, sent|None, ctx|None) - // - PyObjectHandle newArgs = Py_BuildValue(STRCAST("((), O, O, O, O)"), response, ex, sent, ctx); - - return beginBuiltin(reinterpret_cast(self), "ice_id", newArgs.get()); -} - -#ifdef WIN32 -extern "C" -#endif -static PyObject* -proxyEndIceId(ProxyObject* self, PyObject* args) -{ - return endBuiltin(reinterpret_cast(self), "ice_id", args); -} - #ifdef WIN32 extern "C" #endif @@ -1958,112 +1788,6 @@ proxyIceGetConnectionAsync(ProxyObject* self, PyObject* /*args*/, PyObject* /*kw return future.release(); } -#ifdef WIN32 -extern "C" -#endif -static PyObject* -proxyBeginIceGetConnection(ProxyObject* self, PyObject* args, PyObject* kwds) -{ - assert(self->proxy); - - static char* argNames[] = - { - const_cast("_response"), - const_cast("_ex"), - 0 - }; - - PyObject* response = Py_None; - PyObject* ex = Py_None; - if(!PyArg_ParseTupleAndKeywords(args, kwds, STRCAST("|OO"), argNames, &response, &ex)) - { - return 0; - } - - if(response == Py_None) - { - response = 0; - } - if(ex == Py_None) - { - ex = 0; - } - - if(!response && ex) - { - PyErr_Format(PyExc_RuntimeError, - STRCAST("response callback must also be provided when exception callback is used")); - return 0; - } - - Ice::Callback_Object_ice_getConnectionPtr cb; - if(response || ex) - { - GetConnectionCallbackPtr d = new GetConnectionCallback(*self->communicator, response, ex, "ice_getConnection"); - cb = Ice::newCallback_Object_ice_getConnection(d, &GetConnectionCallback::response, - &GetConnectionCallback::exception); - } - - Ice::AsyncResultPtr result; - try - { - if(cb) - { - result = (*self->proxy)->begin_ice_getConnection(cb); - } - else - { - result = (*self->proxy)->begin_ice_getConnection(); - } - } - catch(const Ice::Exception& e) - { - setPythonException(e); - return 0; - } - - PyObjectHandle communicator = getCommunicatorWrapper(*self->communicator); - return createAsyncResult(result, reinterpret_cast(self), 0, communicator.get()); -} - -#ifdef WIN32 -extern "C" -#endif -static PyObject* -proxyEndIceGetConnection(ProxyObject* self, PyObject* args) -{ - assert(self->proxy); - - PyObject* result; - if(!PyArg_ParseTuple(args, STRCAST("O!"), &AsyncResultType, &result)) - { - return 0; - } - - Ice::AsyncResultPtr r = getAsyncResult(result); - Ice::ConnectionPtr con; - try - { - AllowThreads allowThreads; // Release Python's global interpreter lock during blocking invocations. - con = (*self->proxy)->end_ice_getConnection(r); - } - catch(const Ice::Exception& ex) - { - setPythonException(ex); - return 0; - } - - if(con) - { - return createConnection(con, *self->communicator); - } - else - { - Py_INCREF(Py_None); - return Py_None; - } -} - #ifdef WIN32 extern "C" #endif @@ -2159,102 +1883,6 @@ proxyIceFlushBatchRequestsAsync(ProxyObject* self, PyObject* /*args*/, PyObject* return future.release(); } -#ifdef WIN32 -extern "C" -#endif -static PyObject* -proxyBeginIceFlushBatchRequests(ProxyObject* self, PyObject* args, PyObject* kwds) -{ - assert(self->proxy); - - static char* argNames[] = - { - const_cast("_ex"), - const_cast("_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_Object_ice_flushBatchRequestsPtr cb; - if(ex || sent) - { - FlushCallbackPtr d = new FlushCallback(ex, sent, "ice_flushBatchRequests"); - cb = Ice::newCallback_Object_ice_flushBatchRequests(d, &FlushCallback::exception, &FlushCallback::sent); - } - - Ice::AsyncResultPtr result; - try - { - if(cb) - { - result = (*self->proxy)->begin_ice_flushBatchRequests(cb); - } - else - { - result = (*self->proxy)->begin_ice_flushBatchRequests(); - } - } - catch(const Ice::Exception& e) - { - setPythonException(e); - return 0; - } - - PyObjectHandle communicator = getCommunicatorWrapper(*self->communicator); - return createAsyncResult(result, reinterpret_cast(self), 0, communicator.get()); -} - -#ifdef WIN32 -extern "C" -#endif -static PyObject* -proxyEndIceFlushBatchRequests(ProxyObject* self, PyObject* args) -{ - assert(self->proxy); - - 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->proxy)->end_ice_flushBatchRequests(r); - } - catch(const Ice::Exception& ex) - { - setPythonException(ex); - return 0; - } - - Py_INCREF(Py_None); - return Py_None; -} - namespace IcePy { class AMI_Object_ice_flushBatchRequestsI : public IceUtil::Shared @@ -2353,24 +1981,6 @@ proxyIceInvokeAsync(ProxyObject* self, PyObject* args, PyObject* /*kwds*/) return iceInvokeAsync(reinterpret_cast(self), args); } -#ifdef WIN32 -extern "C" -#endif -static PyObject* -proxyBeginIceInvoke(ProxyObject* self, PyObject* args, PyObject* kwds) -{ - return beginIceInvoke(reinterpret_cast(self), args, kwds); -} - -#ifdef WIN32 -extern "C" -#endif -static PyObject* -proxyEndIceInvoke(ProxyObject* self, PyObject* args) -{ - return endIceInvoke(reinterpret_cast(self), args); -} - static PyObject* checkedCastImpl(ProxyObject* p, const string& id, PyObject* facet, PyObject* ctx, PyObject* type) { @@ -2664,34 +2274,18 @@ static PyMethodDef ProxyMethods[] = PyDoc_STR(STRCAST("ice_isA(type, [ctx]) -> bool")) }, { STRCAST("ice_isAAsync"), reinterpret_cast(proxyIceIsAAsync), METH_VARARGS, PyDoc_STR(STRCAST("ice_isAAsync(type, [ctx]) -> Ice.Future")) }, - { STRCAST("begin_ice_isA"), reinterpret_cast(proxyBeginIceIsA), METH_VARARGS | METH_KEYWORDS, - PyDoc_STR(STRCAST("begin_ice_isA(type[, _response][, _ex][, _sent][, context]) -> Ice.AsyncResult")) }, - { STRCAST("end_ice_isA"), reinterpret_cast(proxyEndIceIsA), METH_VARARGS, - PyDoc_STR(STRCAST("end_ice_isA(Ice.AsyncResult) -> bool")) }, { STRCAST("ice_ping"), reinterpret_cast(proxyIcePing), METH_VARARGS, PyDoc_STR(STRCAST("ice_ping([ctx]) -> None")) }, { STRCAST("ice_pingAsync"), reinterpret_cast(proxyIcePingAsync), METH_VARARGS, PyDoc_STR(STRCAST("ice_pingAsync([ctx]) -> Ice.Future")) }, - { STRCAST("begin_ice_ping"), reinterpret_cast(proxyBeginIcePing), METH_VARARGS | METH_KEYWORDS, - PyDoc_STR(STRCAST("begin_ice_ping([_response][, _ex][, _sent][, context]) -> Ice.AsyncResult")) }, - { STRCAST("end_ice_ping"), reinterpret_cast(proxyEndIcePing), METH_VARARGS, - PyDoc_STR(STRCAST("end_ice_ping(Ice.AsyncResult) -> None")) }, { STRCAST("ice_ids"), reinterpret_cast(proxyIceIds), METH_VARARGS, PyDoc_STR(STRCAST("ice_ids([ctx]) -> list")) }, { STRCAST("ice_idsAsync"), reinterpret_cast(proxyIceIdsAsync), METH_VARARGS, PyDoc_STR(STRCAST("ice_idsAsync([ctx]) -> Ice.Future")) }, - { STRCAST("begin_ice_ids"), reinterpret_cast(proxyBeginIceIds), METH_VARARGS | METH_KEYWORDS, - PyDoc_STR(STRCAST("begin_ice_ids([_response][, _ex][, _sent][, context]) -> Ice.AsyncResult")) }, - { STRCAST("end_ice_ids"), reinterpret_cast(proxyEndIceIds), METH_VARARGS, - PyDoc_STR(STRCAST("end_ice_ids(Ice.AsyncResult) -> list")) }, { STRCAST("ice_id"), reinterpret_cast(proxyIceId), METH_VARARGS, PyDoc_STR(STRCAST("ice_id([ctx]) -> string")) }, { STRCAST("ice_idAsync"), reinterpret_cast(proxyIceIdAsync), METH_VARARGS, PyDoc_STR(STRCAST("ice_idAsync([ctx]) -> Ice.Future")) }, - { STRCAST("begin_ice_id"), reinterpret_cast(proxyBeginIceId), METH_VARARGS | METH_KEYWORDS, - PyDoc_STR(STRCAST("begin_ice_id([_response][, _ex][, _sent][, context]) -> Ice.AsyncResult")) }, - { STRCAST("end_ice_id"), reinterpret_cast(proxyEndIceId), METH_VARARGS, - PyDoc_STR(STRCAST("end_ice_id(Ice.AsyncResult) -> string")) }, { STRCAST("ice_getIdentity"), reinterpret_cast(proxyIceGetIdentity), METH_NOARGS, PyDoc_STR(STRCAST("ice_getIdentity() -> Ice.Identity")) }, { STRCAST("ice_identity"), reinterpret_cast(proxyIceIdentity), METH_VARARGS, @@ -2792,28 +2386,16 @@ static PyMethodDef ProxyMethods[] = PyDoc_STR(STRCAST("ice_getConnection() -> Ice.Connection")) }, { STRCAST("ice_getConnectionAsync"), reinterpret_cast(proxyIceGetConnectionAsync), METH_NOARGS, PyDoc_STR(STRCAST("ice_getConnectionAsync() -> Ice.Future")) }, - { STRCAST("begin_ice_getConnection"), reinterpret_cast(proxyBeginIceGetConnection), - METH_VARARGS | METH_KEYWORDS, PyDoc_STR(STRCAST("begin_ice_getConnection([_response][, _ex]) -> Ice.AsyncResult")) }, - { STRCAST("end_ice_getConnection"), reinterpret_cast(proxyEndIceGetConnection), METH_VARARGS, - PyDoc_STR(STRCAST("end_ice_getConnection(Ice.AsyncResult) -> Ice.Connection")) }, { STRCAST("ice_getCachedConnection"), reinterpret_cast(proxyIceGetCachedConnection), METH_NOARGS, PyDoc_STR(STRCAST("ice_getCachedConnection() -> Ice.Connection")) }, { STRCAST("ice_flushBatchRequests"), reinterpret_cast(proxyIceFlushBatchRequests), METH_NOARGS, PyDoc_STR(STRCAST("ice_flushBatchRequests() -> void")) }, { STRCAST("ice_flushBatchRequestsAsync"), reinterpret_cast(proxyIceFlushBatchRequestsAsync), METH_NOARGS, PyDoc_STR(STRCAST("ice_flushBatchRequestsAsync() -> Ice.Future")) }, - { STRCAST("begin_ice_flushBatchRequests"), reinterpret_cast(proxyBeginIceFlushBatchRequests), - METH_VARARGS | METH_KEYWORDS, PyDoc_STR(STRCAST("begin_ice_flushBatchRequests([_ex][, _sent]) -> Ice.AsyncResult")) }, - { STRCAST("end_ice_flushBatchRequests"), reinterpret_cast(proxyEndIceFlushBatchRequests), METH_VARARGS, - PyDoc_STR(STRCAST("end_ice_flushBatchRequests(Ice.AsyncResult) -> void")) }, { STRCAST("ice_invoke"), reinterpret_cast(proxyIceInvoke), METH_VARARGS, PyDoc_STR(STRCAST("ice_invoke(operation, mode, inParams) -> bool, outParams")) }, { STRCAST("ice_invokeAsync"), reinterpret_cast(proxyIceInvokeAsync), METH_VARARGS | METH_KEYWORDS, PyDoc_STR(STRCAST("ice_invokeAsync(op, mode, inParams[, context]) -> Ice.Future")) }, - { STRCAST("begin_ice_invoke"), reinterpret_cast(proxyBeginIceInvoke), METH_VARARGS | METH_KEYWORDS, - PyDoc_STR(STRCAST("begin_ice_invoke(op, mode, inParams[, _response][, _ex][, _sent][, context]) -> Ice.AsyncResult")) }, - { STRCAST("end_ice_invoke"), reinterpret_cast(proxyEndIceInvoke), METH_VARARGS, - PyDoc_STR(STRCAST("end_ice_invoke(Ice.AsyncResult) -> (bool, results)")) }, { STRCAST("ice_checkedCast"), reinterpret_cast(proxyIceCheckedCast), METH_VARARGS | METH_CLASS, PyDoc_STR(STRCAST("ice_checkedCast(proxy, id[, facetOrContext[, context]]) -> proxy")) }, { STRCAST("ice_uncheckedCast"), reinterpret_cast(proxyIceUncheckedCast), METH_VARARGS | METH_CLASS, diff --git a/python/python/Ice/__init__.py b/python/python/Ice/__init__.py index 5f1950fccee..600b2c48994 100644 --- a/python/python/Ice/__init__.py +++ b/python/python/Ice/__init__.py @@ -974,12 +974,6 @@ def flushBatchRequests(self, compress): def flushBatchRequestsAsync(self, compress): return self._impl.flushBatchRequestsAsync(compress) - def begin_flushBatchRequests(self, compress, _ex=None, _sent=None): - return self._impl.begin_flushBatchRequests(compress, _ex, _sent) - - def end_flushBatchRequests(self, r): - return self._impl.end_flushBatchRequests(r) - def createAdmin(self, adminAdapter, adminIdentity): return self._impl.createAdmin(adminAdapter, adminIdentity) diff --git a/python/test/Ice/ami/AllTests.py b/python/test/Ice/ami/AllTests.py index fad0eba4646..e629f9858bd 100644 --- a/python/test/Ice/ami/AllTests.py +++ b/python/test/Ice/ami/AllTests.py @@ -395,834 +395,8 @@ def allTests(helper, communicator, collocated): testController = Test.TestIntfControllerPrx.uncheckedCast(obj) - sys.stdout.write("testing begin/end invocation... ") - sys.stdout.flush() - ctx = {} - - result = p.begin_ice_isA("::Test::TestIntf") - test(p.end_ice_isA(result)) - result = p.begin_ice_isA("::Test::TestIntf", context=ctx) - test(p.end_ice_isA(result)) - - result = p.begin_ice_ping() - p.end_ice_ping(result) - result = p.begin_ice_ping(context=ctx) - p.end_ice_ping(result) - - result = p.begin_ice_id() - test(p.end_ice_id(result) == "::Test::TestIntf") - result = p.begin_ice_id(context=ctx) - test(p.end_ice_id(result) == "::Test::TestIntf") - - result = p.begin_ice_ids() - test(len(p.end_ice_ids(result)) == 2) - result = p.begin_ice_ids(context=ctx) - test(len(p.end_ice_ids(result)) == 2) - - if not collocated: - result = p.begin_ice_getConnection() - test(p.end_ice_getConnection(result) != None) - - result = p.begin_op() - p.end_op(result) - result = p.begin_op(context=ctx) - p.end_op(result) - - result = p.begin_opWithResult() - test(p.end_opWithResult(result) == 15) - result = p.begin_opWithResult(context=ctx) - test(p.end_opWithResult(result) == 15) - - result = p.begin_opWithUE() - try: - p.end_opWithUE(result) - test(False) - except Test.TestIntfException: - pass - result = p.begin_opWithUE(context=ctx) - try: - p.end_opWithUE(result) - test(False) - except Test.TestIntfException: - pass - - print("ok") - - sys.stdout.write("testing response callback... ") - sys.stdout.flush() - - ctx = {} - cb = ResponseCallback() - cookie = 5 - cbWC = ResponseCallbackWC(cookie) - - p.begin_ice_isA(Test.TestIntf.ice_staticId(), cb.isA, cb.ex) - cb.check() - p.begin_ice_isA(Test.TestIntf.ice_staticId(), lambda r: cbWC.isA(r, cookie), lambda ex: cbWC.ex(ex, cookie)) - cbWC.check() - p.begin_ice_isA(Test.TestIntf.ice_staticId(), cb.isA, cb.ex, context=ctx) - cb.check() - p.begin_ice_isA(Test.TestIntf.ice_staticId(), lambda r: cbWC.isA(r, cookie), lambda ex: cbWC.ex(ex, cookie), - context=ctx) - cbWC.check() - - p.begin_ice_ping(cb.ping, cb.ex) - cb.check() - p.begin_ice_ping(lambda: cbWC.ping(cookie), lambda ex: cbWC.ex(ex, cookie)) - cbWC.check() - p.begin_ice_ping(cb.ping, cb.ex, context=ctx) - cb.check() - p.begin_ice_ping(lambda: cbWC.ping(cookie), lambda: cbWC.ex(ex, cookie), context=ctx) - cbWC.check() - - p.begin_ice_id(cb.id, cb.ex) - cb.check() - p.begin_ice_id(lambda id: cbWC.id(id, cookie), lambda ex: cbWC.ex(ex, cookie)) - cbWC.check() - p.begin_ice_id(cb.id, cb.ex, context=ctx) - cb.check() - p.begin_ice_id(lambda id: cbWC.id(id, cookie), lambda ex: cbWC.ex(ex, cookie), context=ctx) - cbWC.check() - - p.begin_ice_ids(cb.ids, cb.ex) - cb.check() - p.begin_ice_ids(lambda ids: cbWC.ids(ids, cookie), lambda ex: cbWC.ex(ex, cookie)) - cbWC.check() - p.begin_ice_ids(cb.ids, cb.ex, context=ctx) - cb.check() - p.begin_ice_ids(lambda ids: cbWC.ids(ids, cookie), lambda ex: cbWC.ex(ex, cookie), context=ctx) - cbWC.check() - - if not collocated: - p.begin_ice_getConnection(cb.connection, cb.ex) - cb.check() - p.begin_ice_getConnection(lambda conn: cbWC.connection(conn, cookie), lambda ex: cbWC.ex(ex, cookie)) - cbWC.check() - - p.begin_op(cb.op, cb.ex) - cb.check() - p.begin_op(lambda: cbWC.op(cookie), lambda ex: cbWC.ex(ex, cookie)) - cbWC.check() - p.begin_op(cb.op, cb.ex, context=ctx) - cb.check() - p.begin_op(lambda: cbWC.op(cookie), lambda ex: cbWC.ex(ex, cookie), context=ctx) - cbWC.check() - - p.begin_opWithResult(cb.opWithResult, cb.ex) - cb.check() - p.begin_opWithResult(lambda r: cbWC.opWithResult(r, cookie), lambda ex: cbWC.ex(ex, cookie)) - cbWC.check() - p.begin_opWithResult(cb.opWithResult, cb.ex, context=ctx) - cb.check() - p.begin_opWithResult(lambda r: cbWC.opWithResult(r, cookie), lambda ex: cbWC.ex(ex, cookie), context=ctx) - cbWC.check() - - p.begin_opWithUE(cb.op, cb.opWithUE) - cb.check() - p.begin_opWithUE(lambda: cbWC.op(cookie), lambda ex: cbWC.opWithUE(ex, cookie)) - cbWC.check() - p.begin_opWithUE(cb.op, cb.opWithUE, context=ctx) - cb.check() - p.begin_opWithUE(lambda: cbWC.op(cookie), lambda ex: cbWC.opWithUE(ex, cookie), context=ctx) - cbWC.check() - - print("ok") - - sys.stdout.write("testing local exceptions... ") - sys.stdout.flush() - - indirect = Test.TestIntfPrx.uncheckedCast(p.ice_adapterId("dummy")) - - r = indirect.begin_op() - try: - indirect.end_op(r) - test(False) - except Ice.NoEndpointException: - pass - - try: - p.ice_oneway().begin_opWithResult() - test(False) - except RuntimeError: - pass - - # - # Check that CommunicatorDestroyedException is raised directly. - # - if p.ice_getConnection(): - initData = Ice.InitializationData() - initData.properties = communicator.getProperties().clone() - ic = Ice.initialize(initData) - obj = ic.stringToProxy(p.ice_toString()) - p2 = Test.TestIntfPrx.checkedCast(obj) - ic.destroy(); - - try: - p2.begin_op() - test(False) - except Ice.CommunicatorDestroyedException: - pass - - print("ok") - - sys.stdout.write("testing local exceptions with response callback... ") - sys.stdout.flush() - - i = Test.TestIntfPrx.uncheckedCast(p.ice_adapterId("dummy")) - cb = ExceptionCallback() - cookie = 5 - cbWC = ExceptionCallbackWC(cookie) - - i.begin_ice_isA(Test.TestIntf.ice_staticId(), cb.response, cb.ex) - cb.check() - i.begin_ice_isA(Test.TestIntf.ice_staticId(), lambda b: cbWC.response(b, cookie), lambda ex: cbWC.ex(ex, cookie)) - cbWC.check() - - i.begin_ice_ping(cb.response, cb.ex) - cb.check() - i.begin_ice_ping(lambda: cbWC.response(cookie), lambda ex: cbWC.ex(ex, cookie)) - cbWC.check() - - i.begin_ice_id(cb.response, cb.ex) - cb.check() - i.begin_ice_id(lambda id: cbWC.response(id, cookie), lambda ex: cbWC.ex(ex, cookie)) - cbWC.check() - - i.begin_ice_ids(cb.response, cb.ex) - cb.check() - i.begin_ice_ids(lambda ids: cbWC.response(ids, cookie), lambda ex: cbWC.ex(ex, cookie)) - cbWC.check() - - if not collocated: - i.begin_ice_getConnection(cb.response, cb.ex) - cb.check() - i.begin_ice_getConnection(lambda conn: cbWC.response(conn, cookie), lambda ex: cbWC.ex(ex, cookie)) - cbWC.check() - - i.begin_op(cb.response, cb.ex) - cb.check() - i.begin_op(lambda: cbWC.response(cookie), lambda ex: cbWC.ex(ex, cookie)) - cbWC.check() - - print("ok") - - sys.stdout.write("testing exception callback... ") - sys.stdout.flush() - - cb = ExceptionCallback() - cookie = 5 - cbWC = ExceptionCallbackWC(cookie) - - # Ensures no exception is called when response is received. - p.begin_ice_isA(Test.TestIntf.ice_staticId(), cb.nullResponse, cb.noEx) - p.begin_ice_isA(Test.TestIntf.ice_staticId(), lambda b: cbWC.nullResponse(b, cookie), - lambda ex: cbWC.noEx(ex, cookie)) - p.begin_op(cb.nullResponse, cb.noEx) - p.begin_op(lambda: cbWC.nullResponse(cookie), lambda ex: cbWC.noEx(ex, cookie)) - - # If response is a user exception, it should be received. - p.begin_opWithUE(cb.nullResponse, cb.opWithUE) - cb.check() - p.begin_opWithUE(lambda: cbWC.nullResponse(cookie), lambda ex: cbWC.opWithUE(ex, cookie)) - cbWC.check() - - print("ok") - - sys.stdout.write("testing sent callback... ") - sys.stdout.flush() - - cb = SentCallback() - cookie = 5 - cbWC = SentCallbackWC(cookie) - - p.begin_ice_isA("", cb.response, cb.ex, cb.sent) - cb.check() - p.begin_ice_isA("", lambda b: cbWC.response(b, cookie), lambda ex: cbWC.ex(ex, cookie), - lambda ss: cbWC.sent(ss, cookie)) - cbWC.check() - - p.begin_ice_ping(cb.response, cb.ex, cb.sent) - cb.check() - p.begin_ice_ping(lambda: cbWC.response(cookie), lambda ex: cbWC.ex(ex, cookie), lambda ss: cbWC.sent(ss, cookie)) - cbWC.check() - - p.begin_ice_id(cb.response, cb.ex, cb.sent) - cb.check() - p.begin_ice_id(lambda id: cbWC.response(id, cookie), lambda ex: cbWC.ex(ex, cookie), - lambda ss: cbWC.sent(ss, cookie)) - cbWC.check() - - p.begin_ice_ids(cb.response, cb.ex, cb.sent) - cb.check() - p.begin_ice_ids(lambda ids: cbWC.response(ids, cookie), lambda ex: cbWC.ex(ex, cookie), - lambda ss: cbWC.sent(ss, cookie)) - cbWC.check() - - p.begin_op(cb.response, cb.ex, cb.sent) - cb.check() - p.begin_op(lambda: cbWC.response(cookie), lambda ex: cbWC.ex(ex, cookie), lambda ss: cbWC.sent(ss, cookie)) - cbWC.check() - - cbs = [] - b = [random.randint(0, 255) for x in range(0, 1024)] - seq = bytes(b) - testController.holdAdapter() - try: - cb = SentCallback() - while(p.begin_opWithPayload(seq, None, cb.ex, cb.sent).sentSynchronously()): - cbs.append(cb) - cb = SentCallback() - except Exception as ex: - testController.resumeAdapter() - raise ex - testController.resumeAdapter() - for r in cbs: - r.check() - - print("ok") - - sys.stdout.write("testing illegal arguments... ") - sys.stdout.flush() - - result = p.begin_op() - p.end_op(result) - try: - p.end_op(result) - test(False) - except RuntimeError: - pass - - result = p.begin_op() - try: - p.end_opWithResult(result) - test(False) - except RuntimeError: - pass - - print("ok") - - sys.stdout.write("testing unexpected exceptions from callback... ") - sys.stdout.flush() - - q = Test.TestIntfPrx.uncheckedCast(p.ice_adapterId("dummy")) - throwTypes = [ LocalException, UserException, OtherException ] - - for t in throwTypes: - cb = Thrower(t) - cookie = 5 - - p.begin_op(cb.op, cb.noEx) - cb.check() - - def thrower(future): - try: - future.result() - except: - test(False) - throwEx(t) - f = p.opAsync() - try: - f.add_done_callback(thrower) - except Exception as ex: - try: - throwEx(t) - except Exception as ex2: - test(type(ex) == type(ex2)) - 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(lambda f, s: throwEx(f)) - f.result() - - p.begin_op(lambda: cb.noOpWC(cookie), lambda ex: cb.exWC(ex, cookie), lambda ss: cb.sentWC(ss, cookie)) - cb.check() - - q.begin_op(None, cb.ex) - cb.check() - - q.begin_op(None, lambda ex: cb.exWC(ex, cookie)) - cb.check() - - print("ok") - - sys.stdout.write("testing batch requests with proxy... ") - sys.stdout.flush() - - cookie = 5 - - # - # Without cookie. - # - test(p.opBatchCount() == 0) - b1 = p.ice_batchOneway() - b1.opBatch() - b1.opBatch() - cb = FlushCallback() - r = b1.begin_ice_flushBatchRequests(cb.exception, cb.sent) - cb.check() - test(r.isSent()) - test(r.isCompleted()) - test(p.waitForBatch(2)) - - # - # With cookie. - # - test(p.opBatchCount() == 0) - b1 = p.ice_batchOneway() - b1.opBatch() - b1.opBatch() - cb = FlushCallback(cookie) - r = b1.begin_ice_flushBatchRequests(lambda ex: cb.exceptionWC(ex, cookie), lambda ss: cb.sentWC(ss, cookie)) - cb.check() - test(p.waitForBatch(2)) - - if p.ice_getConnection(): # No collocation optimization - # - # Exception without cookie. - # - test(p.opBatchCount() == 0) - b1 = p.ice_batchOneway() - b1.opBatch() - b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) - cb = FlushCallback() - r = b1.begin_ice_flushBatchRequests(cb.exception, cb.sent) - cb.check() - test(r.isSent()) - test(r.isCompleted()) - test(p.waitForBatch(1)) - - # - # Exception with cookie. - # - test(p.opBatchCount() == 0) - b1 = p.ice_batchOneway() - b1.opBatch() - b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) - cb = FlushCallback(cookie) - r = b1.begin_ice_flushBatchRequests(lambda ex: cb.exceptionWC(ex, cookie), lambda ss: cb.sentWC(ss, cookie)) - cb.check() - test(p.waitForBatch(1)) - - print("ok") - - if p.ice_getConnection(): # No collocation optimization - sys.stdout.write("testing batch requests with connection... ") - sys.stdout.flush() - - cookie = 5 - - # - # Without cookie. - # - test(p.opBatchCount() == 0) - b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway()) - b1.opBatch() - b1.opBatch() - cb = FlushCallback() - r = b1.ice_getConnection().begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy, cb.exception, cb.sent) - cb.check() - test(r.isSent()) - test(r.isCompleted()) - test(p.waitForBatch(2)) - - # - # With cookie. - # - test(p.opBatchCount() == 0) - b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway()) - b1.opBatch() - b1.opBatch() - cb = FlushCallback(cookie) - r = b1.ice_getConnection().begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy, - lambda ex: cb.exceptionWC(ex, cookie), - lambda ss: cb.sentWC(ss, cookie)) - cb.check() - test(p.waitForBatch(2)) - - # - # Exception without cookie. - # - test(p.opBatchCount() == 0) - b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway()) - b1.opBatch() - b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) - cb = FlushExCallback() - r = b1.ice_getConnection().begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy, cb.exception, cb.sent) - cb.check() - test(not r.isSent()) - test(r.isCompleted()) - test(p.opBatchCount() == 0) - - # - # Exception with cookie. - # - test(p.opBatchCount() == 0) - b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway()) - b1.opBatch() - b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) - cb = FlushExCallback(cookie) - r = b1.ice_getConnection().begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy, - lambda ex: cb.exceptionWC(ex, cookie), - lambda ss: cb.sentWC(ss, cookie)) - cb.check() - test(p.opBatchCount() == 0) - - print("ok") - - sys.stdout.write("testing batch requests with communicator... ") - sys.stdout.flush() - - # - # 1 connection. - # - test(p.opBatchCount() == 0) - b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway()) - b1.opBatch() - b1.opBatch() - cb = FlushCallback() - r = communicator.begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy, cb.exception, cb.sent) - cb.check() - test(r.isSent()) - test(r.isCompleted()) - test(p.waitForBatch(2)) - - # - # 1 connection. - # - test(p.opBatchCount() == 0) - b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway()) - b1.opBatch() - b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) - cb = FlushCallback() - r = communicator.begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy, cb.exception, cb.sent) - cb.check() - test(r.isSent()) # Exceptions are ignored! - test(r.isCompleted()) - test(p.opBatchCount() == 0) - - # - # 2 connections. - # - test(p.opBatchCount() == 0) - b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway()) - b2 = Test.TestIntfPrx.uncheckedCast(p.ice_connectionId("2").ice_getConnection().createProxy( - p.ice_getIdentity()).ice_batchOneway()) - b2.ice_getConnection() # Ensure connection is established. - b1.opBatch() - b1.opBatch() - b2.opBatch() - b2.opBatch() - cb = FlushCallback() - r = communicator.begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy, cb.exception, cb.sent) - cb.check() - test(r.isSent()) - test(r.isCompleted()) - test(p.waitForBatch(4)) - - # - # 2 connections - 1 failure. - # - # All connections should be flushed even if there are failures on some connections. - # Exceptions should not be reported. - # - test(p.opBatchCount() == 0) - b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway()) - b2 = Test.TestIntfPrx.uncheckedCast(p.ice_connectionId("2").ice_getConnection().createProxy( - p.ice_getIdentity()).ice_batchOneway()) - b2.ice_getConnection() # Ensure connection is established. - b1.opBatch() - b2.opBatch() - b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) - cb = FlushCallback() - r = communicator.begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy, cb.exception, cb.sent) - cb.check() - test(r.isSent()) # Exceptions are ignored! - test(r.isCompleted()) - test(p.waitForBatch(1)) - - # - # 2 connections - 2 failures. - # - # The sent callback should be invoked even if all connections fail. - # - test(p.opBatchCount() == 0) - b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway()) - b2 = Test.TestIntfPrx.uncheckedCast(p.ice_connectionId("2").ice_getConnection().createProxy( - p.ice_getIdentity()).ice_batchOneway()) - b2.ice_getConnection() # Ensure connection is established. - b1.opBatch() - b2.opBatch() - b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) - b2.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) - cb = FlushCallback() - r = communicator.begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy, cb.exception, cb.sent) - cb.check() - test(r.isSent()) # Exceptions are ignored! - test(r.isCompleted()) - test(p.opBatchCount() == 0) - - print("ok") - - sys.stdout.write("testing AsyncResult operations... ") - sys.stdout.flush() - - indirect = Test.TestIntfPrx.uncheckedCast(p.ice_adapterId("dummy")) - r = indirect.begin_op() - try: - r.waitForCompleted() - r.throwLocalException() - test(False) - except Ice.NoEndpointException: - pass - - testController.holdAdapter() - r1 = None - r2 = None - try: - r1 = p.begin_op() - b = [random.randint(0, 255) for x in range(0, 1024)] - seq = bytes(b) - while(True): - r2 = p.begin_opWithPayload(seq) - if not r2.sentSynchronously(): - break - - test(r1 == r1) - test(r1 != r2) - - if p.ice_getConnection(): - test((r1.sentSynchronously() and r1.isSent() and not r1.isCompleted()) or - (not r1.sentSynchronously() and not r1.isCompleted())); - - test(not r2.sentSynchronously() and not r2.isCompleted()); - except Exception as ex: - testController.resumeAdapter() - raise ex - testController.resumeAdapter() - - r1.waitForSent() - test(r1.isSent()) - - r2.waitForSent() - test(r2.isSent()) - - r1.waitForCompleted() - test(r1.isCompleted()) - - r2.waitForCompleted() - test(r2.isCompleted()) - - test(r1.getOperation() == "op") - test(r2.getOperation() == "opWithPayload") - - # - # Twoway - # - r = p.begin_ice_ping() - test(r.getOperation() == "ice_ping") - test(r.getConnection() == None) # Expected - test(r.getCommunicator() == communicator) - test(r.getProxy() == p) - p.end_ice_ping(r) - - # - # Oneway - # - p2 = p.ice_oneway() - r = p2.begin_ice_ping() - test(r.getOperation() == "ice_ping") - test(r.getConnection() == None) # Expected - test(r.getCommunicator() == communicator) - test(r.getProxy() == p2) - - # - # Batch request via proxy - # - p2 = p.ice_batchOneway() - p2.ice_ping() - r = p2.begin_ice_flushBatchRequests() - test(r.getConnection() == None) # Expected - test(r.getCommunicator() == communicator) - test(r.getProxy() == p2) - p2.end_ice_flushBatchRequests(r) - - if p.ice_getConnection(): - # - # Batch request via connection - # - con = p.ice_getConnection() - p2 = p.ice_batchOneway() - p2.ice_ping() - r = con.begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy) - test(r.getConnection() == con) - test(r.getCommunicator() == communicator) - test(r.getProxy() == None) # Expected - con.end_flushBatchRequests(r) - - # - # Batch request via communicator - # - p2 = p.ice_batchOneway() - p2.ice_ping() - r = communicator.begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy) - test(r.getConnection() == None) # Expected - test(r.getCommunicator() == communicator) - test(r.getProxy() == None) # Expected - communicator.end_flushBatchRequests(r) - - if(p.ice_getConnection()): - r1 = None; - r2 = None; - - b = [random.randint(0, 255) for x in range(0, 10024)] - seq = bytes(b) - - testController.holdAdapter() - - for x in range(0, 200): # 2MB - r = p.begin_opWithPayload(seq) - - test(not r.isSent()) - - r1 = p.begin_ice_ping() - r2 = p.begin_ice_id() - r1.cancel() - r2.cancel() - try: - p.end_ice_ping(r1) - test(False) - except(Ice.InvocationCanceledException): - pass - - try: - p.end_ice_id(r2) - test(False) - except(Ice.InvocationCanceledException): - pass - - testController.resumeAdapter() - p.ice_ping() - test(not r1.isSent() and r1.isCompleted()) - test(not r2.isSent() and r2.isCompleted()) - - testController.holdAdapter() - - r1 = p.begin_op() - r2 = p.begin_ice_id() - r1.waitForSent() - r2.waitForSent() - r1.cancel() - r2.cancel() - try: - p.end_op(r1) - test(False) - except: - pass - try: - p.end_ice_id(r2) - test(False) - except: - pass - testController.resumeAdapter() - - print("ok") - if p.ice_getConnection() and p.supportsAMD(): - sys.stdout.write("testing graceful close connection with wait... ") - sys.stdout.flush() - - # - # Local case: begin a request, close the connection gracefully, and make sure it waits - # for the request to complete. - # - cb = CallbackBase() - con = p.ice_getConnection() - con.setCloseCallback(lambda con: cb.called()) - f = p.sleepAsync(100) - con.close(Ice.ConnectionClose.GracefullyWithWait) # Blocks until the request completes. - f.result() # Should complete successfully. - cb.check() - - # - # Remote case. - # - 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.begin_opWithPayload(seq)) - if not p.begin_close(Test.CloseMode.GracefullyWithWait).isSent(): - for i in range(0, maxQueue): - r = p.begin_opWithPayload(seq) - results.append(r) - if r.isSent(): - done = False - maxQueue = maxQueue * 2 - break - else: - maxQueue = maxQueue * 2 - done = False - for r in results: - r.waitForCompleted() - try: - r.throwLocalException() - except Ice.LocalException: - test(False) - - print("ok") - sys.stdout.write("testing graceful close connection without wait... ") sys.stdout.flush() diff --git a/python/test/Ice/exceptions/AllTests.py b/python/test/Ice/exceptions/AllTests.py index 762058d61ef..5cd26055c08 100644 --- a/python/test/Ice/exceptions/AllTests.py +++ b/python/test/Ice/exceptions/AllTests.py @@ -832,121 +832,4 @@ def allTests(helper, communicator): pass print("ok") - sys.stdout.write("catching exact types with AMI mapping... ") - sys.stdout.flush() - - cb = Callback() - thrower.begin_throwAasA(1, cb.response, cb.exception_AasA) - cb.check() - - cb = Callback() - thrower.begin_throwAorDasAorD(1, cb.response, cb.exception_AorDasAorD) - cb.check() - - cb = Callback() - thrower.begin_throwAorDasAorD(-1, cb.response, cb.exception_AorDasAorD) - cb.check() - - cb = Callback() - thrower.begin_throwBasB(1, 2, cb.response, cb.exception_BasB) - cb.check() - - cb = Callback() - thrower.begin_throwCasC(1, 2, 3, cb.response, cb.exception_CasC) - cb.check() - - cb = Callback() - thrower.begin_throwModA(1, 2, cb.response, cb.exception_ModA) - cb.check() - - print("ok") - - sys.stdout.write("catching derived types with AMI mapping... ") - sys.stdout.flush() - - cb = Callback() - thrower.begin_throwBasA(1, 2, cb.response, cb.exception_BasA) - cb.check() - - cb = Callback() - thrower.begin_throwCasA(1, 2, 3, cb.response, cb.exception_CasA) - cb.check() - - cb = Callback() - thrower.begin_throwCasB(1, 2, 3, cb.response, cb.exception_CasB) - cb.check() - - print("ok") - - if thrower.supportsUndeclaredExceptions(): - sys.stdout.write("catching unknown user exception with AMI mapping... ") - sys.stdout.flush() - - cb = Callback() - thrower.begin_throwUndeclaredA(1, cb.response, cb.exception_UndeclaredA) - cb.check() - - cb = Callback() - thrower.begin_throwUndeclaredB(1, 2, cb.response, cb.exception_UndeclaredB) - cb.check() - - cb = Callback() - thrower.begin_throwUndeclaredC(1, 2, 3, cb.response, cb.exception_UndeclaredC) - cb.check() - - print("ok") - - sys.stdout.write("catching object not exist exception with AMI mapping... ") - sys.stdout.flush() - - id = Ice.stringToIdentity("does not exist") - thrower2 = Test.ThrowerPrx.uncheckedCast(thrower.ice_identity(id)) - cb = Callback(communicator) - thrower2.begin_throwAasA(1, cb.response, cb.exception_AasAObjectNotExist) - cb.check() - - print("ok") - - sys.stdout.write("catching facet not exist exception with AMI mapping... ") - sys.stdout.flush() - - thrower2 = Test.ThrowerPrx.uncheckedCast(thrower, "no such facet") - cb = Callback() - thrower2.begin_throwAasA(1, cb.response, cb.exception_AasAFacetNotExist) - cb.check() - - print("ok") - - sys.stdout.write("catching operation not exist exception with AMI mapping... ") - sys.stdout.flush() - - cb = Callback() - thrower4 = Test.WrongOperationPrx.uncheckedCast(thrower) - thrower4.begin_noSuchOperation(cb.response, cb.exception_noSuchOperation) - cb.check() - - print("ok") - - sys.stdout.write("catching unknown local exception with AMI mapping... ") - sys.stdout.flush() - - cb = Callback() - thrower.begin_throwLocalException(cb.response, cb.exception_LocalException) - cb.check() - - cb = Callback() - thrower.begin_throwLocalExceptionIdempotent(cb.response, cb.exception_LocalException) - cb.check() - - print("ok") - - sys.stdout.write("catching unknown non-Ice exception with AMI mapping... ") - sys.stdout.flush() - - cb = Callback() - thrower.begin_throwNonIceException(cb.response, cb.exception_NonIceException) - cb.check() - - print("ok") - return thrower diff --git a/python/test/Ice/operations/AllTests.py b/python/test/Ice/operations/AllTests.py index 457dbceaf96..e73b7d7022b 100644 --- a/python/test/Ice/operations/AllTests.py +++ b/python/test/Ice/operations/AllTests.py @@ -2,8 +2,8 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, Twoways, TwowaysFuture, TwowaysAMI, Oneways, OnewaysFuture, OnewaysAMI, BatchOneways, sys -import BatchOnewaysAMI, BatchOnewaysFuture +import Ice, Test, Twoways, TwowaysFuture, Oneways, OnewaysFuture, BatchOneways, sys +import BatchOnewaysFuture def test(b): if not b: @@ -32,21 +32,11 @@ def allTests(helper, communicator): TwowaysFuture.twowaysFuture(helper, cl) print("ok") - sys.stdout.write("testing twoway operations with AMI... ") - sys.stdout.flush() - TwowaysAMI.twowaysAMI(helper, cl) - print("ok") - sys.stdout.write("testing oneway operations with futures... ") sys.stdout.flush() OnewaysFuture.onewaysFuture(helper, cl) print("ok") - sys.stdout.write("testing oneway operations with AMI... ") - sys.stdout.flush() - OnewaysAMI.onewaysAMI(helper, cl) - print("ok") - sys.stdout.write("testing batch oneway operations... ") sys.stdout.flush() BatchOneways.batchOneways(cl) @@ -59,12 +49,6 @@ def allTests(helper, communicator): BatchOnewaysFuture.batchOneways(derived) print("ok") - sys.stdout.write("testing batch oneway operations with AMI... ") - sys.stdout.flush() - BatchOnewaysAMI.batchOneways(cl) - BatchOnewaysAMI.batchOneways(derived) - print("ok") - sys.stdout.write("testing server shutdown... ") sys.stdout.flush() cl.shutdown() diff --git a/python/test/Ice/operations/BatchOneways.py b/python/test/Ice/operations/BatchOneways.py index b06c08068eb..7c2ce9c019d 100644 --- a/python/test/Ice/operations/BatchOneways.py +++ b/python/test/Ice/operations/BatchOneways.py @@ -27,7 +27,8 @@ def enqueue(self, request, count, size): self._size = size if self._size + request.getSize() > 25000: - request.getProxy().begin_ice_flushBatchRequests() + f = request.getProxy().ice_flushBatchRequestsAsync() + f.result() self._size = 18 # header if self._enabled: diff --git a/python/test/Ice/operations/BatchOnewaysAMI.py b/python/test/Ice/operations/BatchOnewaysAMI.py deleted file mode 100644 index 7fe4b27733e..00000000000 --- a/python/test/Ice/operations/BatchOnewaysAMI.py +++ /dev/null @@ -1,75 +0,0 @@ -# -# Copyright (c) ZeroC, Inc. All rights reserved. -# - -import Ice, Test, array, sys, threading, time - -def test(b): - if not b: - raise RuntimeError('test assertion failed') - -class Callback: - def __init__(self): - self._called = False - self._cond = threading.Condition() - - def check(self): - with self._cond: - while not self._called: - self._cond.wait() - self._called = False - - def called(self): - with self._cond: - self._called = True - self._cond.notify() - -def batchOneways(p): - - bs1 = bytes([0 for x in range(0, 10 * 1024)]) - batch = Test.MyClassPrx.uncheckedCast(p.ice_batchOneway()) - - batch.end_ice_flushBatchRequests(batch.begin_ice_flushBatchRequests()) # Empty flush - test(batch.begin_ice_flushBatchRequests().isSent()) # Empty flush - test(batch.begin_ice_flushBatchRequests().isCompleted()) # Empty flush - test(batch.begin_ice_flushBatchRequests().sentSynchronously()) # Empty flush - - for i in range(30): - batch.begin_opByteSOneway(bs1, lambda: 0, lambda ex: test(False) ) - - count = 0 - while count < 27: # 3 * 9 requests auto-flushed. - count += p.opByteSOnewayCallCount() - time.sleep(0.01) - - if p.ice_getConnection(): - - batch1 = Test.MyClassPrx.uncheckedCast(p.ice_batchOneway()) - batch2 = Test.MyClassPrx.uncheckedCast(p.ice_batchOneway()) - - 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(Ice.ConnectionClose.GracefullyWithWait) - 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(Ice.ConnectionClose.GracefullyWithWait) - - batch1.end_ice_ping(batch1.begin_ice_ping()) - batch2.end_ice_ping(batch2.begin_ice_ping()) - - identity = Ice.Identity() - identity.name = "invalid"; - batch3 = batch.ice_identity(identity) - batch3.ice_ping() - batch3.end_ice_flushBatchRequests(batch3.begin_ice_flushBatchRequests()) - - # Make sure that a bogus batch request doesn't cause troubles to other ones. - batch3.ice_ping() - batch.ice_ping() - batch.end_ice_flushBatchRequests(batch.begin_ice_flushBatchRequests()) - batch.ice_ping() diff --git a/python/test/Ice/operations/OnewaysAMI.py b/python/test/Ice/operations/OnewaysAMI.py deleted file mode 100644 index 18ffd5f86b3..00000000000 --- a/python/test/Ice/operations/OnewaysAMI.py +++ /dev/null @@ -1,76 +0,0 @@ -# -# Copyright (c) ZeroC, Inc. All rights reserved. -# - -import Ice, Test, threading - -def test(b): - if not b: - raise RuntimeError('test assertion failed') - -class CallbackBase: - def __init__(self): - self._called = False - self._cond = threading.Condition() - - def check(self): - with self._cond: - while not self._called: - self._cond.wait() - self._called = False - - def called(self): - with self._cond: - self._called = True - self._cond.notify() - -class Callback(CallbackBase): - def sent(self, sentSynchronously): - self.called() - - def noException(self, ex): - test(False) - -def onewaysAMI(helper, proxy): - communicator = helper.communicator() - p = Test.MyClassPrx.uncheckedCast(proxy.ice_oneway()) - - cb = Callback() - p.begin_ice_ping(None, cb.noException, cb.sent) - cb.check() - - try: - p.begin_ice_isA(Test.MyClass.ice_staticId()) - test(False) - except RuntimeError: - pass - - try: - p.begin_ice_id() - test(False) - except RuntimeError: - pass - - try: - p.begin_ice_ids() - test(False) - except RuntimeError: - pass - - cb = Callback() - p.begin_opVoid(None, cb.noException, cb.sent) - cb.check() - - cb = Callback() - p.begin_opIdempotent(None, cb.noException, cb.sent) - cb.check() - - cb = Callback() - p.begin_opNonmutating(None, cb.noException, cb.sent) - cb.check() - - try: - p.begin_opByte(0xff, 0x0f) - test(False) - except RuntimeError: - pass diff --git a/python/test/Ice/operations/TwowaysAMI.py b/python/test/Ice/operations/TwowaysAMI.py deleted file mode 100644 index 5a3a6fcfe79..00000000000 --- a/python/test/Ice/operations/TwowaysAMI.py +++ /dev/null @@ -1,1165 +0,0 @@ -# -# Copyright (c) ZeroC, Inc. All rights reserved. -# - -import Ice, Test, math, sys, threading - -def test(b): - if not b: - raise RuntimeError('test assertion failed') - -class CallbackBase: - def __init__(self): - self._called = False - self._cond = threading.Condition() - - def check(self): - with self._cond: - while not self._called: - self._cond.wait() - self._called = False - - def called(self): - with self._cond: - self._called = True - self._cond.notify() - -class Callback(CallbackBase): - def __init__(self, communicator=None): - CallbackBase.__init__(self) - self._communicator = communicator - - def ping(self): - self.called() - - def isA(self, r): - test(r) - self.called() - - def id(self, id): - test(id == "::Test::MyDerivedClass") - self.called() - - def ids(self, ids): - test(len(ids) == 3) - self.called() - - def opVoid(self): - self.called() - - def opByte(self, r, b): - test(b == 0xf0) - test(r == 0xff) - self.called() - - def opBool(self, r, b): - test(b) - test(not r) - self.called() - - def opShortIntLong(self, r, s, i, l): - test(s == 10) - test(i == 11) - test(l == 12) - test(r == 12) - self.called() - - def opFloatDouble(self, r, f, d): - test(f - 3.14 < 0.001) - test(d == 1.1E10) - test(r == 1.1E10) - self.called() - - def opString(self, r, s): - test(s == "world hello") - test(r == "hello world") - self.called() - - def opMyEnum(self, r, e): - test(e == Test.MyEnum.enum2) - test(r == Test.MyEnum.enum3) - self.called() - - def opMyClass(self, r, c1, c2): - test(c1.ice_getIdentity() == Ice.stringToIdentity("test")) - test(c2.ice_getIdentity() == Ice.stringToIdentity("noSuchIdentity")) - test(r.ice_getIdentity() == Ice.stringToIdentity("test")) - # We can't do the callbacks below in serialize mode - if self._communicator.getProperties().getPropertyAsInt("Ice.Client.ThreadPool.Serialize") == 0: - r.opVoid() - c1.opVoid() - try: - c2.opVoid() - test(False) - except Ice.ObjectNotExistException: - pass - self.called() - - def opStruct(self, rso, so): - test(rso.p == None) - test(rso.e == Test.MyEnum.enum2) - test(rso.s.s == "def") - test(so.e == Test.MyEnum.enum3) - test(so.s.s == "a new string") - # We can't do the callbacks below in serialize mode. - if self._communicator.getProperties().getPropertyAsInt("Ice.ThreadPool.Client.Serialize") == 0: - so.p.opVoid() - self.called() - - def opByteS(self, rso, bso): - test(len(bso) == 4) - test(len(rso) == 8) - test(bso[0] == 0x22) - test(bso[1] == 0x12) - test(bso[2] == 0x11) - test(bso[3] == 0x01) - test(rso[0] == 0x01) - test(rso[1] == 0x11) - test(rso[2] == 0x12) - test(rso[3] == 0x22) - test(rso[4] == 0xf1) - test(rso[5] == 0xf2) - test(rso[6] == 0xf3) - test(rso[7] == 0xf4) - self.called() - - def opBoolS(self, rso, bso): - test(len(bso) == 4) - test(bso[0]) - test(bso[1]) - test(not bso[2]) - test(not bso[3]) - test(len(rso) == 3) - test(not rso[0]) - test(rso[1]) - test(rso[2]) - self.called() - - def opShortIntLongS(self, rso, sso, iso, lso): - test(len(sso) == 3) - test(sso[0] == 1) - test(sso[1] == 2) - test(sso[2] == 3) - test(len(iso) == 4) - test(iso[0] == 8) - test(iso[1] == 7) - test(iso[2] == 6) - test(iso[3] == 5) - test(len(lso) == 6) - test(lso[0] == 10) - test(lso[1] == 30) - test(lso[2] == 20) - test(lso[3] == 10) - test(lso[4] == 30) - test(lso[5] == 20) - test(len(rso) == 3) - test(rso[0] == 10) - test(rso[1] == 30) - test(rso[2] == 20) - self.called() - - def opFloatDoubleS(self, rso, fso, dso): - test(len(fso) == 2) - test(fso[0] - 3.14 < 0.001) - test(fso[1] - 1.11 < 0.001) - test(len(dso) == 3) - test(dso[0] == 1.3E10) - test(dso[1] == 1.2E10) - test(dso[2] == 1.1E10) - test(len(rso) == 5) - test(rso[0] == 1.1E10) - test(rso[1] == 1.2E10) - test(rso[2] == 1.3E10) - test(rso[3] - 3.14 < 0.001) - test(rso[4] - 1.11 < 0.001) - self.called() - - def opStringS(self, rso, sso): - test(len(sso) == 4) - test(sso[0] == "abc") - test(sso[1] == "de") - test(sso[2] == "fghi") - test(sso[3] == "xyz") - test(len(rso) == 3) - test(rso[0] == "fghi") - test(rso[1] == "de") - test(rso[2] == "abc") - self.called() - - def opByteSS(self, rso, bso): - test(len(bso) == 2) - test(len(bso[0]) == 1) - test(len(bso[1]) == 3) - test(len(rso) == 4) - test(len(rso[0]) == 3) - test(len(rso[1]) == 1) - test(len(rso[2]) == 1) - test(len(rso[3]) == 2) - test(bso[0][0] == 0xff) - test(bso[1][0] == 0x01) - test(bso[1][1] == 0x11) - test(bso[1][2] == 0x12) - test(rso[0][0] == 0x01) - test(rso[0][1] == 0x11) - test(rso[0][2] == 0x12) - test(rso[1][0] == 0xff) - test(rso[2][0] == 0x0e) - test(rso[3][0] == 0xf2) - test(rso[3][1] == 0xf1) - self.called() - - def opBoolSS(self, rso, bso): - test(len(bso) == 4); - test(len(bso[0]) == 1); - test(bso[0][0]); - test(len(bso[1]) == 1); - test(not bso[1][0]); - test(len(bso[2]) == 2); - test(bso[2][0]); - test(bso[2][1]); - test(len(bso[3]) == 3); - test(not bso[3][0]); - test(not bso[3][1]); - test(bso[3][2]); - test(len(rso) == 3); - test(len(rso[0]) == 2); - test(rso[0][0]); - test(rso[0][1]); - test(len(rso[1]) == 1); - test(not rso[1][0]); - test(len(rso[2]) == 1); - test(rso[2][0]); - self.called(); - - def opShortIntLongSS(self, rso, sso, iso, lso): - test(len(rso) == 1); - test(len(rso[0]) == 2); - test(rso[0][0] == 496); - test(rso[0][1] == 1729); - test(len(sso) == 3); - test(len(sso[0]) == 3); - test(sso[0][0] == 1); - test(sso[0][1] == 2); - test(sso[0][2] == 5); - test(len(sso[1]) == 1); - test(sso[1][0] == 13); - test(len(sso[2]) == 0); - test(len(iso) == 2); - test(len(iso[0]) == 1); - test(iso[0][0] == 42); - test(len(iso[1]) == 2); - test(iso[1][0] == 24); - test(iso[1][1] == 98); - test(len(lso) == 2); - test(len(lso[0]) == 2); - test(lso[0][0] == 496); - test(lso[0][1] == 1729); - test(len(lso[1]) == 2); - test(lso[1][0] == 496); - test(lso[1][1] == 1729); - self.called(); - - def opFloatDoubleSS(self, rso, fso, dso): - test(len(fso) == 3) - test(len(fso[0]) == 1) - test(fso[0][0] - 3.14 < 0.001) - test(len(fso[1]) == 1) - test(fso[1][0] - 1.11 < 0.001) - test(len(fso[2]) == 0) - test(len(dso) == 1) - test(len(dso[0]) == 3) - test(dso[0][0] == 1.1E10) - test(dso[0][1] == 1.2E10) - test(dso[0][2] == 1.3E10) - test(len(rso) == 2) - test(len(rso[0]) == 3) - test(rso[0][0] == 1.1E10) - test(rso[0][1] == 1.2E10) - test(rso[0][2] == 1.3E10) - test(len(rso[1]) == 3) - test(rso[1][0] == 1.1E10) - test(rso[1][1] == 1.2E10) - test(rso[1][2] == 1.3E10) - self.called() - - def opStringSS(self, rso, sso): - test(len(sso) == 5) - test(len(sso[0]) == 1) - test(sso[0][0] == "abc") - test(len(sso[1]) == 2) - test(sso[1][0] == "de") - test(sso[1][1] == "fghi") - test(len(sso[2]) == 0) - test(len(sso[3]) == 0) - test(len(sso[4]) == 1) - test(sso[4][0] == "xyz") - test(len(rso) == 3) - test(len(rso[0]) == 1) - test(rso[0][0] == "xyz") - test(len(rso[1]) == 0) - test(len(rso[2]) == 0) - self.called() - - def opByteBoolD(self, ro, do): - di1 = {10: True, 100: False} - test(do == di1) - test(len(ro) == 4) - test(ro[10]) - test(not ro[11]) - test(not ro[100]) - test(ro[101]) - self.called() - - def opShortIntD(self, ro, do): - di1 = {110: -1, 1100: 123123} - test(do == di1) - test(len(ro) == 4) - test(ro[110] == -1) - test(ro[111] == -100) - test(ro[1100] == 123123) - test(ro[1101] == 0) - self.called() - - def opLongFloatD(self, ro, do): - di1 = {999999110: -1.1, 999999111: 123123.2} - for k in do: - test(math.fabs(do[k] - di1[k]) < 0.01) - test(len(ro) == 4) - test(ro[999999110] - -1.1 < 0.01) - test(ro[999999120] - -100.4 < 0.01) - test(ro[999999111] - 123123.2 < 0.01) - test(ro[999999130] - 0.5 < 0.01) - self.called() - - def opStringStringD(self, ro, do): - di1 = {'foo': 'abc -1.1', 'bar': 'abc 123123.2'} - test(do == di1) - test(len(ro) == 4) - test(ro["foo"] == "abc -1.1") - test(ro["FOO"] == "abc -100.4") - test(ro["bar"] == "abc 123123.2") - test(ro["BAR"] == "abc 0.5") - self.called() - - def opStringMyEnumD(self, ro, do): - di1 = {'abc': Test.MyEnum.enum1, '': Test.MyEnum.enum2} - test(do == di1) - test(len(ro) == 4) - test(ro["abc"] == Test.MyEnum.enum1) - test(ro["qwerty"] == Test.MyEnum.enum3) - test(ro[""] == Test.MyEnum.enum2) - test(ro["Hello!!"] == Test.MyEnum.enum2) - self.called() - - def opMyEnumStringD(self, ro, do): - di1 = {Test.MyEnum.enum1: 'abc'} - test(do == di1) - test(len(ro) == 3) - test(ro[Test.MyEnum.enum1] == "abc") - test(ro[Test.MyEnum.enum2] == "Hello!!") - test(ro[Test.MyEnum.enum3] == "qwerty") - self.called() - - def opMyStructMyEnumD(self, ro, do): - s11 = Test.MyStruct() - s11.i = 1 - s11.j = 1 - s12 = Test.MyStruct() - s12.i = 1 - s12.j = 2 - s22 = Test.MyStruct() - s22.i = 2 - s22.j = 2 - s23 = Test.MyStruct() - s23.i = 2 - s23.j = 3 - di1 = {s11: Test.MyEnum.enum1, s12: Test.MyEnum.enum2} - test(do == di1) - test(len(ro) == 4) - test(ro[s11] == Test.MyEnum.enum1) - test(ro[s12] == Test.MyEnum.enum2) - test(ro[s22] == Test.MyEnum.enum3) - test(ro[s23] == Test.MyEnum.enum2) - self.called() - - def opByteBoolDS(self, ro, do): - test(len(ro) == 2) - test(len(ro[0]) == 3) - test(ro[0][10]) - test(not ro[0][11]) - test(ro[0][101]) - test(len(ro[1]) == 2) - test(ro[1][10]) - test(not ro[1][100]) - test(len(do) == 3) - test(len(do[0]) == 2) - test(not do[0][100]) - test(not do[0][101]) - test(len(do[1]) == 2) - test(do[1][10]) - test(not do[1][100]) - test(len(do[2]) == 3) - test(do[2][10]) - test(not do[2][11]) - test(do[2][101]) - self.called() - - def opShortIntDS(self, ro, do): - test(len(ro) == 2) - test(len(ro[0]) == 3) - test(ro[0][110] == -1) - test(ro[0][111] == -100) - test(ro[0][1101] == 0) - test(len(ro[1]) == 2) - test(ro[1][110] == -1) - test(ro[1][1100] == 123123) - test(len(do) == 3) - test(len(do[0]) == 1) - test(do[0][100] == -1001) - test(len(do[1]) == 2) - test(do[1][110] == -1) - test(do[1][1100] == 123123) - test(len(do[2]) == 3) - test(do[2][110] == -1) - test(do[2][111] == -100) - test(do[2][1101] == 0) - self.called() - - def opLongFloatDS(self, ro, do): - test(len(ro) == 2) - test(len(ro[0]) == 3) - test(ro[0][999999110] - -1.1 < 0.01) - test(ro[0][999999120] - -100.4 < 0.01) - test(ro[0][999999130] - 0.5 < 0.01) - test(len(ro[1]) == 2) - test(ro[1][999999110] - -1.1 < 0.01) - test(ro[1][999999111] - 123123.2 < 0.01) - test(len(do) == 3) - test(len(do[0]) == 1) - test(do[0][999999140] - 3.14 < 0.01) - test(len(do[1]) == 2) - test(do[1][999999110] - -1.1 < 0.01) - test(do[1][999999111] - 123123.2 < 0.01) - test(len(do[2]) == 3) - test(do[2][999999110] - -1.1 < 0.01) - test(do[2][999999120] - -100.4 < 0.01) - test(do[2][999999130] - 0.5 < 0.01) - self.called() - - def opStringStringDS(self, ro, do): - test(len(ro) == 2) - test(len(ro[0]) == 3) - test(ro[0]["foo"] == "abc -1.1") - test(ro[0]["FOO"] == "abc -100.4") - test(ro[0]["BAR"] == "abc 0.5") - test(len(ro[1]) == 2) - test(ro[1]["foo"] == "abc -1.1") - test(ro[1]["bar"] == "abc 123123.2") - test(len(do) == 3) - test(len(do[0]) == 1) - test(do[0]["f00"] == "ABC -3.14") - test(len(do[1]) == 2) - test(do[1]["foo"] == "abc -1.1") - test(do[1]["bar"] == "abc 123123.2") - test(len(do[2]) == 3) - test(do[2]["foo"] == "abc -1.1") - test(do[2]["FOO"] == "abc -100.4") - test(do[2]["BAR"] == "abc 0.5") - self.called() - - def opStringMyEnumDS(self, ro, do): - test(len(ro) == 2) - test(len(ro[0]) == 3) - test(ro[0]["abc"] == Test.MyEnum.enum1) - test(ro[0]["qwerty"] == Test.MyEnum.enum3) - test(ro[0]["Hello!!"] == Test.MyEnum.enum2) - test(len(ro[1]) == 2) - test(ro[1]["abc"] == Test.MyEnum.enum1) - test(ro[1][""] == Test.MyEnum.enum2) - test(len(do) == 3) - test(len(do[0]) == 1) - test(do[0]["Goodbye"] == Test.MyEnum.enum1) - test(len(do[1]) == 2) - test(do[1]["abc"] == Test.MyEnum.enum1) - test(do[1][""] == Test.MyEnum.enum2) - test(len(do[2]) == 3) - test(do[2]["abc"] == Test.MyEnum.enum1) - test(do[2]["qwerty"] == Test.MyEnum.enum3) - test(do[2]["Hello!!"] == Test.MyEnum.enum2) - self.called() - - def opMyEnumStringDS(self, ro, do): - test(len(ro) == 2) - test(len(ro[0]) == 2) - test(ro[0][Test.MyEnum.enum2] == "Hello!!") - test(ro[0][Test.MyEnum.enum3] == "qwerty") - test(len(ro[1]) == 1) - test(ro[1][Test.MyEnum.enum1] == "abc") - test(len(do) == 3) - test(len(do[0]) == 1) - test(do[0][Test.MyEnum.enum1] == "Goodbye") - test(len(do[1]) == 1) - test(do[1][Test.MyEnum.enum1] == "abc") - test(len(do[2]) == 2) - test(do[2][Test.MyEnum.enum2] == "Hello!!") - test(do[2][Test.MyEnum.enum3] == "qwerty") - self.called() - - def opMyStructMyEnumDS(self, ro, do): - s11 = Test.MyStruct(1, 1) - s12 = Test.MyStruct(1, 2) - s22 = Test.MyStruct(2, 2) - s23 = Test.MyStruct(2, 3) - test(len(ro) == 2) - test(len(ro[0]) == 3) - test(ro[0][s11] == Test.MyEnum.enum1) - test(ro[0][s22] == Test.MyEnum.enum3) - test(ro[0][s23] == Test.MyEnum.enum2) - test(len(ro[1]) == 2) - test(ro[1][s11] == Test.MyEnum.enum1) - test(ro[1][s12] == Test.MyEnum.enum2) - test(len(do) == 3) - test(len(do[0]) == 1) - test(do[0][s23] == Test.MyEnum.enum3) - test(len(do[1]) == 2) - test(do[1][s11] == Test.MyEnum.enum1) - test(do[1][s12] == Test.MyEnum.enum2) - test(len(do[2]) == 3) - test(do[2][s11] == Test.MyEnum.enum1) - test(do[2][s22] == Test.MyEnum.enum3) - test(do[2][s23] == Test.MyEnum.enum2) - self.called() - - def opByteByteSD(self, ro, do): - test(len(do) == 1) - test(len(do[0xf1]) == 2) - test(do[0xf1][0] == 0xf2) - test(do[0xf1][1] == 0xf3) - test(len(ro) == 3) - test(len(ro[0x01]) == 2) - test(ro[0x01][0] == 0x01) - test(ro[0x01][1] == 0x11) - test(len(ro[0x22]) == 1) - test(ro[0x22][0] == 0x12) - test(len(ro[0xf1]) == 2) - test(ro[0xf1][0] == 0xf2) - test(ro[0xf1][1] == 0xf3) - self.called() - - def opBoolBoolSD(self, ro, do): - test(len(do) == 1) - test(len(do[False]) == 2) - test(do[False][0]) - test(not do[False][1]) - test(len(ro) == 2) - test(len(ro[False]) == 2) - test(ro[False][0]) - test(not ro[False][1]) - test(len(ro[True]) == 3) - test(not ro[True][0]) - test(ro[True][1]) - test(ro[True][2]) - self.called() - - def opShortShortSD(self, ro, do): - test(len(do) == 1) - test(len(do[4]) == 2) - test(do[4][0] == 6) - test(do[4][1] == 7) - test(len(ro) == 3) - test(len(ro[1]) == 3) - test(ro[1][0] == 1) - test(ro[1][1] == 2) - test(ro[1][2] == 3) - test(len(ro[2]) == 2) - test(ro[2][0] == 4) - test(ro[2][1] == 5) - test(len(ro[4]) == 2) - test(ro[4][0] == 6) - test(ro[4][1] == 7) - self.called() - - def opIntIntSD(self, ro, do): - test(len(do) == 1) - test(len(do[400]) == 2) - test(do[400][0] == 600) - test(do[400][1] == 700) - test(len(ro) == 3) - test(len(ro[100]) == 3) - test(ro[100][0] == 100) - test(ro[100][1] == 200) - test(ro[100][2] == 300) - test(len(ro[200]) == 2) - test(ro[200][0] == 400) - test(ro[200][1] == 500) - test(len(ro[400]) == 2) - test(ro[400][0] == 600) - test(ro[400][1] == 700) - self.called() - - def opLongLongSD(self, ro, do): - test(len(do) == 1) - test(len(do[999999992]) == 2) - test(do[999999992][0] == 999999110) - test(do[999999992][1] == 999999120) - test(len(ro) == 3) - test(len(ro[999999990]) == 3) - test(ro[999999990][0] == 999999110) - test(ro[999999990][1] == 999999111) - test(ro[999999990][2] == 999999110) - test(len(ro[999999991]) == 2) - test(ro[999999991][0] == 999999120) - test(ro[999999991][1] == 999999130) - test(len(ro[999999992]) == 2) - test(ro[999999992][0] == 999999110) - test(ro[999999992][1] == 999999120) - self.called() - - def opStringFloatSD(self, ro, do): - test(len(do) == 1) - test(len(do["aBc"]) == 2) - test(do["aBc"][0] - -3.14 < 0.10) - test(do["aBc"][1] - 3.14 < 0.10) - test(len(ro) == 3) - test(len(ro["abc"]) == 3) - test(ro["abc"][0] - -1.1 < 0.10) - test(ro["abc"][1] - 123123.2 < 0.10) - test(ro["abc"][2] - 100.0 < 0.10) - test(len(ro["ABC"]) == 2) - test(ro["ABC"][0] - 42.24 < 0.10) - test(ro["ABC"][1] - -1.61 < 0.10) - test(len(ro["aBc"]) == 2) - test(ro["aBc"][0] - -3.14 < 0.10) - test(ro["aBc"][1] - 3.14 < 0.10) - self.called() - - def opStringDoubleSD(self, ro, do): - test(len(do) == 1) - test(len(do[""]) == 2) - test(do[""][0] == 1.6E10) - test(do[""][1] == 1.7E10) - test(len(ro) == 3) - test(len(ro["Hello!!"]) == 3) - test(ro["Hello!!"][0] == 1.1E10) - test(ro["Hello!!"][1] == 1.2E10) - test(ro["Hello!!"][2] == 1.3E10) - test(len(ro["Goodbye"]) == 2) - test(ro["Goodbye"][0] == 1.4E10) - test(ro["Goodbye"][1] == 1.5E10) - test(len(ro[""]) == 2) - test(ro[""][0] == 1.6E10) - test(ro[""][1] == 1.7E10) - self.called() - - def opStringStringSD(self, ro, do): - test(len(do) == 1) - test(len(do["ghi"]) == 2) - test(do["ghi"][0] == "and") - test(do["ghi"][1] == "xor") - test(len(ro) == 3) - test(len(ro["abc"]) == 3) - test(ro["abc"][0] == "abc") - test(ro["abc"][1] == "de") - test(ro["abc"][2] == "fghi") - test(len(ro["def"]) == 2) - test(ro["def"][0] == "xyz") - test(ro["def"][1] == "or") - test(len(ro["ghi"]) == 2) - test(ro["ghi"][0] == "and") - test(ro["ghi"][1] == "xor") - self.called() - - def opMyEnumMyEnumSD(self, ro, do): - test(len(do) == 1) - test(len(do[Test.MyEnum.enum1]) == 2) - test(do[Test.MyEnum.enum1][0] == Test.MyEnum.enum3) - test(do[Test.MyEnum.enum1][1] == Test.MyEnum.enum3) - test(len(ro) == 3) - test(len(ro[Test.MyEnum.enum3]) == 3) - test(ro[Test.MyEnum.enum3][0] == Test.MyEnum.enum1) - test(ro[Test.MyEnum.enum3][1] == Test.MyEnum.enum1) - test(ro[Test.MyEnum.enum3][2] == Test.MyEnum.enum2) - test(len(ro[Test.MyEnum.enum2]) == 2) - test(ro[Test.MyEnum.enum2][0] == Test.MyEnum.enum1) - test(ro[Test.MyEnum.enum2][1] == Test.MyEnum.enum2) - test(len(ro[Test.MyEnum.enum1]) == 2) - test(ro[Test.MyEnum.enum1][0] == Test.MyEnum.enum3) - test(ro[Test.MyEnum.enum1][1] == Test.MyEnum.enum3) - self.called() - - def opIntS(self, r): - for j in range(0, len(r)): - test(r[j] == -j) - self.called() - - def opIdempotent(self): - self.called() - - def opNonmutating(self): - self.called() - - def opDerived(self): - self.called() - - def exCB(self, ex): - test(False) - -def twowaysAMI(helper, p): - communicator = helper.communicator() - cb = Callback() - p.begin_ice_ping(cb.ping, cb.exCB) - cb.check() - - cb = Callback() - p.begin_ice_isA(Test.MyClass.ice_staticId(), cb.isA, cb.exCB) - cb.check() - - cb = Callback() - p.begin_ice_id(cb.id, cb.exCB) - cb.check() - - cb = Callback() - p.begin_ice_ids(cb.ids, cb.exCB) - cb.check() - - r = p.begin_opVoid() - p.end_opVoid(r) - - cb = Callback() - p.begin_opVoid(cb.opVoid, cb.exCB) - cb.check() - - r = p.begin_opByte(0xff, 0x0f) - (ret, p3) = p.end_opByte(r) - test(p3 == 0xf0) - test(ret == 0xff) - - cb = Callback() - p.begin_opByte(0xff, 0x0f, cb.opByte, cb.exCB) - cb.check() - - cb = Callback() - p.begin_opBool(True, False, cb.opBool, cb.exCB) - cb.check() - - cb = Callback() - p.begin_opShortIntLong(10, 11, 12, cb.opShortIntLong, cb.exCB) - cb.check() - - cb = Callback() - p.begin_opFloatDouble(3.14, 1.1E10, cb.opFloatDouble, cb.exCB) - cb.check() - - cb = Callback() - p.begin_opString("hello", "world", cb.opString, cb.exCB) - cb.check() - - cb = Callback() - p.begin_opMyEnum(Test.MyEnum.enum2, cb.opMyEnum, cb.exCB) - cb.check() - - cb = Callback(communicator) - p.begin_opMyClass(p, cb.opMyClass, cb.exCB) - cb.check() - - si1 = Test.Structure() - si1.p = p - si1.e = Test.MyEnum.enum3 - si1.s = Test.AnotherStruct() - si1.s.s = "abc" - si2 = Test.Structure() - si2.p = None - si2.e = Test.MyEnum.enum2 - si2.s = Test.AnotherStruct() - si2.s.s = "def" - - cb = Callback(communicator) - p.begin_opStruct(si1, si2, cb.opStruct, cb.exCB) - cb.check() - - bsi1 = (0x01, 0x11, 0x12, 0x22) - bsi2 = (0xf1, 0xf2, 0xf3, 0xf4) - - cb = Callback() - p.begin_opByteS(bsi1, bsi2, cb.opByteS, cb.exCB) - cb.check() - - bsi1 = (True, True, False) - bsi2 = (False,) - - cb = Callback() - p.begin_opBoolS(bsi1, bsi2, cb.opBoolS, cb.exCB) - cb.check() - - ssi = (1, 2, 3) - isi = (5, 6, 7, 8) - lsi = (10, 30, 20) - - cb = Callback() - p.begin_opShortIntLongS(ssi, isi, lsi, cb.opShortIntLongS, cb.exCB) - cb.check() - - fsi = (3.14, 1.11) - dsi = (1.1E10, 1.2E10, 1.3E10) - - cb = Callback() - p.begin_opFloatDoubleS(fsi, dsi, cb.opFloatDoubleS, cb.exCB) - cb.check() - - ssi1 = ('abc', 'de', 'fghi') - ssi2 = ('xyz',) - - cb = Callback() - p.begin_opStringS(ssi1, ssi2, cb.opStringS, cb.exCB) - cb.check() - - bsi1 = ((0x01, 0x11, 0x12), (0xff,)) - bsi2 = ((0x0e,), (0xf2, 0xf1)) - - cb = Callback() - p.begin_opByteSS(bsi1, bsi2, cb.opByteSS, cb.exCB) - cb.check() - - bsi1 = ((True,), (False,), (True, True),) - bsi2 = ((False, False, True),) - - cb = Callback() - p.begin_opBoolSS(bsi1, bsi2, cb.opBoolSS, cb.exCB) - cb.check(); - - ssi = ((1,2,5), (13,), ()) - isi = ((24, 98), (42,)) - lsi = ((496, 1729),) - - cb = Callback() - p.begin_opShortIntLongSS(ssi, isi, lsi, cb.opShortIntLongSS, cb.exCB) - cb.check() - - fsi = ((3.14,), (1.11,), ()) - dsi = ((1.1E10, 1.2E10, 1.3E10),) - - cb = Callback() - p.begin_opFloatDoubleSS(fsi, dsi, cb.opFloatDoubleSS, cb.exCB) - cb.check() - - ssi1 = (('abc',), ('de', 'fghi')) - ssi2 = ((), (), ('xyz',)) - - cb = Callback() - p.begin_opStringSS(ssi1, ssi2, cb.opStringSS, cb.exCB) - cb.check() - - di1 = {10: True, 100: False} - di2 = {10: True, 11: False, 101: True} - - cb = Callback() - p.begin_opByteBoolD(di1, di2, cb.opByteBoolD, cb.exCB) - cb.check() - - di1 = {110: -1, 1100: 123123} - di2 = {110: -1, 111: -100, 1101: 0} - - cb = Callback() - p.begin_opShortIntD(di1, di2, cb.opShortIntD, cb.exCB) - cb.check() - - di1 = {999999110: -1.1, 999999111: 123123.2} - di2 = {999999110: -1.1, 999999120: -100.4, 999999130: 0.5} - - cb = Callback() - p.begin_opLongFloatD(di1, di2, cb.opLongFloatD, cb.exCB) - cb.check() - - di1 = {'foo': 'abc -1.1', 'bar': 'abc 123123.2'} - di2 = {'foo': 'abc -1.1', 'FOO': 'abc -100.4', 'BAR': 'abc 0.5'} - - cb = Callback() - p.begin_opStringStringD(di1, di2, cb.opStringStringD, cb.exCB) - cb.check() - - di1 = {'abc': Test.MyEnum.enum1, '': Test.MyEnum.enum2} - di2 = {'abc': Test.MyEnum.enum1, 'qwerty': Test.MyEnum.enum3, 'Hello!!': Test.MyEnum.enum2} - - cb = Callback() - p.begin_opStringMyEnumD(di1, di2, cb.opStringMyEnumD, cb.exCB) - cb.check() - - di1 = {Test.MyEnum.enum1: 'abc'} - di2 = {Test.MyEnum.enum2: 'Hello!!', Test.MyEnum.enum3: 'qwerty'} - - cb = Callback() - p.begin_opMyEnumStringD(di1, di2, cb.opMyEnumStringD, cb.exCB) - cb.check() - - s11 = Test.MyStruct() - s11.i = 1 - s11.j = 1 - s12 = Test.MyStruct() - s12.i = 1 - s12.j = 2 - s22 = Test.MyStruct() - s22.i = 2 - s22.j = 2 - s23 = Test.MyStruct() - s23.i = 2 - s23.j = 3 - di1 = {s11: Test.MyEnum.enum1, s12: Test.MyEnum.enum2} - di2 = {s11: Test.MyEnum.enum1, s22: Test.MyEnum.enum3, s23: Test.MyEnum.enum2} - - cb = Callback() - p.begin_opMyStructMyEnumD(di1, di2, cb.opMyStructMyEnumD, cb.exCB) - cb.check() - - dsi1 = ({ 10: True, 100: False }, { 10: True, 11: False, 101: True }) - dsi2 = ({ 100: False, 101: False },) - - cb = Callback() - p.begin_opByteBoolDS(dsi1, dsi2, cb.opByteBoolDS, cb.exCB) - cb.check() - - dsi1 = ({ 110: -1, 1100: 123123 }, { 110: -1, 111: -100, 1101: 0 }) - dsi2 = ({ 100: -1001 },) - - cb = Callback() - p.begin_opShortIntDS(dsi1, dsi2, cb.opShortIntDS, cb.exCB) - cb.called() - - dsi1 = ({ 999999110: -1.1, 999999111: 123123.2 }, { 999999110: -1.1, 999999120: -100.4, 999999130: 0.5 }) - dsi2 = ({ 999999140: 3.14 },) - - cb = Callback() - p.begin_opLongFloatDS(dsi1, dsi2, cb.opLongFloatDS, cb.exCB) - cb.called() - - dsi1 = ({ "foo": "abc -1.1", "bar": "abc 123123.2" }, { "foo": "abc -1.1", "FOO": "abc -100.4", "BAR": "abc 0.5" }) - dsi2 = ({ "f00": "ABC -3.14" },) - - cb = Callback() - p.begin_opStringStringDS(dsi1, dsi2, cb.opStringStringDS, cb.exCB) - cb.called() - - dsi1 = ( - { "abc": Test.MyEnum.enum1, "": Test.MyEnum.enum2 }, - { "abc": Test.MyEnum.enum1, "qwerty": Test.MyEnum.enum3, "Hello!!": Test.MyEnum.enum2 } - ) - - dsi2 = ({ "Goodbye": Test.MyEnum.enum1 },) - - cb = Callback() - p.begin_opStringMyEnumDS(dsi1, dsi2, cb.opStringMyEnumDS, cb.exCB) - cb.called() - - dsi1 = ({ Test.MyEnum.enum1: 'abc' }, { Test.MyEnum.enum2: 'Hello!!', Test.MyEnum.enum3: 'qwerty'}) - dsi2 = ({ Test.MyEnum.enum1: 'Goodbye' },) - - cb = Callback() - p.begin_opMyEnumStringDS(dsi1, dsi2, cb.opMyEnumStringDS, cb.exCB) - cb.called() - - s11 = Test.MyStruct(1, 1) - s12 = Test.MyStruct(1, 2) - - s22 = Test.MyStruct(2, 2) - s23 = Test.MyStruct(2, 3) - - dsi1 = ( - { s11: Test.MyEnum.enum1, s12: Test.MyEnum.enum2 }, - { s11: Test.MyEnum.enum1, s22: Test.MyEnum.enum3, s23: Test.MyEnum.enum2 } - ) - dsi2 = ({ s23: Test.MyEnum.enum3 },) - - cb = Callback() - p.begin_opMyStructMyEnumDS(dsi1, dsi2, cb.opMyStructMyEnumDS, cb.exCB) - cb.called() - - sdi1 = { 0x01: (0x01, 0x11), 0x22: (0x12,) } - sdi2 = { 0xf1: (0xf2, 0xf3) } - - cb = Callback() - p.begin_opByteByteSD(sdi1, sdi2, cb.opByteByteSD, cb.exCB) - cb.called() - - sdi1 = { False: (True, False), True: (False, True, True) } - sdi2 = { False: (True, False) } - - cb = Callback() - p.begin_opBoolBoolSD(sdi1, sdi2, cb.opBoolBoolSD, cb.exCB) - cb.called() - - sdi1 = { 1: (1, 2, 3), 2: (4, 5) } - sdi2 = { 4: (6, 7) } - - cb = Callback() - p.begin_opShortShortSD(sdi1, sdi2, cb.opShortShortSD, cb.exCB) - cb.called() - - sdi1 = { 100: (100, 200, 300), 200: (400, 500) } - sdi2 = { 400: (600, 700) } - - cb = Callback() - p.begin_opIntIntSD(sdi1, sdi2, cb.opIntIntSD, cb.exCB) - cb.called() - - sdi1 = { 999999990: (999999110, 999999111, 999999110), 999999991: (999999120, 999999130) } - sdi2 = { 999999992: (999999110, 999999120) } - - cb = Callback() - p.begin_opLongLongSD(sdi1, sdi2, cb.opLongLongSD, cb.exCB) - cb.called() - - sdi1 = { "abc": (-1.1, 123123.2, 100.0), "ABC": (42.24, -1.61) } - sdi2 = { "aBc": (-3.14, 3.14) } - - cb = Callback() - p.begin_opStringFloatSD(sdi1, sdi2, cb.opStringFloatSD, cb.exCB) - cb.called() - - sdi1 = { "Hello!!": (1.1E10, 1.2E10, 1.3E10), "Goodbye": (1.4E10, 1.5E10) } - sdi2 = { "": (1.6E10, 1.7E10) } - - cb = Callback() - p.begin_opStringDoubleSD(sdi1, sdi2, cb.opStringDoubleSD, cb.exCB); - cb.called() - - sdi1 = { "abc": ("abc", "de", "fghi") , "def": ("xyz", "or") } - sdi2 = { "ghi": ("and", "xor") } - - cb = Callback() - p.begin_opStringStringSD(sdi1, sdi2, cb.opStringStringSD, cb.exCB) - cb.called() - - sdi1 = { - Test.MyEnum.enum3: (Test.MyEnum.enum1, Test.MyEnum.enum1, Test.MyEnum.enum2), - Test.MyEnum.enum2: (Test.MyEnum.enum1, Test.MyEnum.enum2) - } - sdi2 = { Test.MyEnum.enum1: (Test.MyEnum.enum3, Test.MyEnum.enum3) } - - cb = Callback() - p.begin_opMyEnumMyEnumSD(sdi1, sdi2, cb.opMyEnumMyEnumSD, cb.exCB) - cb.called() - - lengths = ( 0, 1, 2, 126, 127, 128, 129, 253, 254, 255, 256, 257, 1000 ) - for l in lengths: - s = [] - for i in range(l): - s.append(i) - cb = Callback(l) - p.begin_opIntS(s, cb.opIntS, cb.exCB) - cb.check() - - ctx = {'one': 'ONE', 'two': 'TWO', 'three': 'THREE'} - - test(len(p.ice_getContext()) == 0) - r = p.begin_opContext() - c = p.end_opContext(r) - test(c != ctx) - - test(len(p.ice_getContext()) == 0) - r = p.begin_opContext(context=ctx) - c = p.end_opContext(r) - test(c == ctx) - - p2 = Test.MyClassPrx.checkedCast(p.ice_context(ctx)) - test(p2.ice_getContext() == ctx) - r = p2.begin_opContext() - c = p2.end_opContext(r) - test(c == ctx) - - r = p2.begin_opContext(context=ctx) - c = p2.end_opContext(r) - test(c == ctx) - - # - # Test implicit context propagation - # - if p.ice_getConnection(): - impls = ( 'Shared', 'PerThread' ) - for i in impls: - initData = Ice.InitializationData() - initData.properties = communicator.getProperties().clone() - initData.properties.setProperty('Ice.ImplicitContext', i) - ic = Ice.initialize(data=initData) - - ctx = {'one': 'ONE', 'two': 'TWO', 'three': 'THREE'} - - p3 = Test.MyClassPrx.uncheckedCast(ic.stringToProxy("test:{0}".format(helper.getTestEndpoint()))) - - ic.getImplicitContext().setContext(ctx) - test(ic.getImplicitContext().getContext() == ctx) - r = p3.begin_opContext() - c = p3.end_opContext(r) - test(c == ctx) - - ic.getImplicitContext().put('zero', 'ZERO') - - ctx = ic.getImplicitContext().getContext() - r = p3.begin_opContext() - c = p3.end_opContext(r) - test(c == ctx) - - prxContext = {'one': 'UN', 'four': 'QUATRE'} - - combined = {} - combined.update(ctx) - combined.update(prxContext) - test(combined['one'] == 'UN') - - p3 = Test.MyClassPrx.uncheckedCast(p3.ice_context(prxContext)) - ic.getImplicitContext().setContext({}) - r = p3.begin_opContext() - c = p3.end_opContext(r) - test(c == prxContext) - - ic.getImplicitContext().setContext(ctx) - r = p3.begin_opContext() - c = p3.end_opContext(r) - test(c == combined) - - ic.destroy() - - cb = Callback() - p.begin_opIdempotent(cb.opIdempotent, cb.exCB) - cb.check() - - cb = Callback() - p.begin_opNonmutating(cb.opNonmutating, cb.exCB) - cb.check() - - derived = Test.MyDerivedClassPrx.checkedCast(p) - test(derived) - cb = Callback() - derived.begin_opDerived(cb.opDerived, cb.exCB) - cb.check() - - r = p.begin_opByte1(0xFF) - test(p.end_opByte1(r) == 0xFF) - - r = p.begin_opShort1(0x7FFF) - test(p.end_opShort1(r) == 0x7FFF) - - r = p.begin_opInt1(0x7FFFFFFF) - test(p.end_opInt1(r) == 0x7FFFFFFF) - - r = p.begin_opLong1(0x7FFFFFFFFFFFFFFF) - test(p.end_opLong1(r) == 0x7FFFFFFFFFFFFFFF) - - r = p.begin_opFloat1(1.0) - test(p.end_opFloat1(r) == 1.0) - - r = p.begin_opDouble1(1.0) - test(p.end_opDouble1(r) == 1.0) - - r = p.begin_opString1("opString1") - test(p.end_opString1(r) == "opString1") - - r = p.begin_opStringS1(None) - test(len(p.end_opStringS1(r)) == 0) - - r = p.begin_opByteBoolD1(None) - test(len(p.end_opByteBoolD1(r)) == 0) - - r = p.begin_opStringS2(None) - test(len(p.end_opStringS2(r)) == 0) - - r = p.begin_opByteBoolD2(None) - test(len(p.end_opByteBoolD2(r)) == 0) diff --git a/python/test/Ice/timeout/AllTests.py b/python/test/Ice/timeout/AllTests.py index bf52af63926..fa96ef75e4c 100644 --- a/python/test/Ice/timeout/AllTests.py +++ b/python/test/Ice/timeout/AllTests.py @@ -148,22 +148,6 @@ def allTestsWithController(helper, communicator, controller): except Ice.InvocationTimeoutException: test(False) test(connection == to.ice_getConnection()) - - # # - # # Expect InvocationTimeoutException. - # # - # to = Test.TimeoutPrx.uncheckedCast(obj.ice_invocationTimeout(250)) - # cb = new Callback() - # to.begin_sleep(500, newCallback_Timeout_sleep(cb, &Callback.responseEx, &Callback.exceptionEx)) - # cb.check() - - # # - # # Expect success. - # # - # to = Test.TimeoutPrx.uncheckedCast(obj.ice_invocationTimeout(1000)) - # cb = new Callback() - # to.begin_sleep(100, newCallback_Timeout_sleep(cb, &Callback.response, &Callback.exception)) - # cb.check() print("ok") sys.stdout.write("testing close timeout... ")