summaryrefslogtreecommitdiff
path: root/python/modules/IcePy/Communicator.cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2016-12-09 15:18:08 -0800
committerMark Spruiell <mes@zeroc.com>2016-12-09 15:18:08 -0800
commit3b7e9f99b61538e0bbd6f07deeb7f7cb12013ed5 (patch)
treea8edbf5d1043527cc50880b34ee83458ed7e4855 /python/modules/IcePy/Communicator.cpp
parentMerge remote-tracking branch 'origin/3.6' (diff)
downloadice-3b7e9f99b61538e0bbd6f07deeb7f7cb12013ed5.tar.bz2
ice-3b7e9f99b61538e0bbd6f07deeb7f7cb12013ed5.tar.xz
ice-3b7e9f99b61538e0bbd6f07deeb7f7cb12013ed5.zip
ICE-7138 - new Python AMI mapping based on futures and modified AMD mapping
Diffstat (limited to 'python/modules/IcePy/Communicator.cpp')
-rw-r--r--python/modules/IcePy/Communicator.cpp59
1 files changed, 57 insertions, 2 deletions
diff --git a/python/modules/IcePy/Communicator.cpp b/python/modules/IcePy/Communicator.cpp
index eb223c85853..927c3cab5d2 100644
--- a/python/modules/IcePy/Communicator.cpp
+++ b/python/modules/IcePy/Communicator.cpp
@@ -723,6 +723,48 @@ communicatorFlushBatchRequests(CommunicatorObject* self)
extern "C"
#endif
static PyObject*
+communicatorFlushBatchRequestsAsync(CommunicatorObject* self, PyObject* /*args*/, PyObject* /*kwds*/)
+{
+ assert(self->communicator);
+ const string op = "flushBatchRequests";
+
+ FlushAsyncCallbackPtr d = new FlushAsyncCallback(op);
+ Ice::Callback_Communicator_flushBatchRequestsPtr cb =
+ Ice::newCallback_Communicator_flushBatchRequests(d, &FlushAsyncCallback::exception, &FlushAsyncCallback::sent);
+
+ Ice::AsyncResultPtr result;
+
+ try
+ {
+ AllowThreads allowThreads; // Release Python's global interpreter lock during remote invocations.
+
+ result = (*self->communicator)->begin_flushBatchRequests(cb);
+ }
+ catch(const Ice::Exception& ex)
+ {
+ setPythonException(ex);
+ return 0;
+ }
+
+ PyObjectHandle asyncResultObj = createAsyncResult(result, 0, 0, self->wrapper);
+ if(!asyncResultObj.get())
+ {
+ return 0;
+ }
+
+ PyObjectHandle future = createFuture(op, asyncResultObj.get());
+ if(!future.get())
+ {
+ return 0;
+ }
+ d->setFuture(future.get());
+ return future.release();
+}
+
+#ifdef WIN32
+extern "C"
+#endif
+static PyObject*
communicatorBeginFlushBatchRequests(CommunicatorObject* self, PyObject* args, PyObject* kwds)
{
assert(self->communicator);
@@ -1608,6 +1650,8 @@ static PyMethodDef CommunicatorMethods[] =
PyDoc_STR(STRCAST("setDefaultLocator(proxy) -> None")) },
{ STRCAST("flushBatchRequests"), reinterpret_cast<PyCFunction>(communicatorFlushBatchRequests), METH_NOARGS,
PyDoc_STR(STRCAST("flushBatchRequests() -> None")) },
+ { STRCAST("flushBatchRequestsAsync"), reinterpret_cast<PyCFunction>(communicatorFlushBatchRequestsAsync),
+ METH_NOARGS, PyDoc_STR(STRCAST("flushBatchRequestsAsync() -> Ice.Future")) },
{ STRCAST("begin_flushBatchRequests"), reinterpret_cast<PyCFunction>(communicatorBeginFlushBatchRequests),
METH_VARARGS | METH_KEYWORDS,
PyDoc_STR(STRCAST("begin_flushBatchRequests([_ex][, _sent]) -> Ice.AsyncResult")) },
@@ -1734,8 +1778,19 @@ IcePy::getCommunicatorWrapper(const Ice::CommunicatorPtr& communicator)
CommunicatorMap::iterator p = _communicatorMap.find(communicator);
assert(p != _communicatorMap.end());
CommunicatorObject* obj = reinterpret_cast<CommunicatorObject*>(p->second);
- Py_INCREF(obj->wrapper);
- return obj->wrapper;
+ if(obj->wrapper)
+ {
+ Py_INCREF(obj->wrapper);
+ return obj->wrapper;
+ }
+ else
+ {
+ //
+ // Communicator must have been destroyed already.
+ //
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
}
extern "C"