diff -r 26249f82c15d Modules/_asynciomodule.c --- a/Modules/_asynciomodule.c Mon Oct 17 18:13:46 2016 +0200 +++ b/Modules/_asynciomodule.c Tue Oct 18 03:18:42 2016 +0900 @@ -51,55 +51,79 @@ int fut_blocking; PyObject *dict; PyObject *fut_weakreflist; } FutureObj; -static int -_schedule_callbacks(FutureObj *fut) +PyDoc_STRVAR(pydoc_schedule_callbacks, + "Internal: Ask the event loop to call all callbacks.\n" + "\n" + "The callbacks are scheduled to be called as soon as possible. Also\n" + "clears the callback list.\n" +); + +static PyObject * +FutureObj_schedule_callbacks(FutureObj *fut) { Py_ssize_t len; PyObject* iters; int i; if (fut->fut_callbacks == NULL) { PyErr_SetString(PyExc_RuntimeError, "NULL callbacks"); - return -1; + return NULL; } len = PyList_GET_SIZE(fut->fut_callbacks); if (len == 0) { - return 0; + Py_RETURN_NONE; } iters = PyList_GetSlice(fut->fut_callbacks, 0, len); if (iters == NULL) { - return -1; + return NULL; } if (PyList_SetSlice(fut->fut_callbacks, 0, len, NULL) < 0) { Py_DECREF(iters); - return -1; + return NULL; } for (i = 0; i < len; i++) { PyObject *handle = NULL; PyObject *cb = PyList_GET_ITEM(iters, i); handle = _PyObject_CallMethodId( fut->fut_loop, &PyId_call_soon, "OO", cb, fut, NULL); if (handle == NULL) { Py_DECREF(iters); - return -1; + return NULL; } else { Py_DECREF(handle); } } Py_DECREF(iters); + Py_RETURN_NONE; +} + +// Call fut._schedule_callbacks() +// Note that _schedule_callbacks() can be overridden. +static int +_schedule_callbacks(FutureObj *fut) +{ + _Py_IDENTIFIER(_schedule_callbacks); + + PyObject *ret = _PyObject_CallMethodIdObjArgs( + (PyObject*)fut, &PyId__schedule_callbacks, NULL); + + if (ret == NULL) { + return -1; + } + Py_DECREF(ret); return 0; } static int FutureObj_init(FutureObj *fut, PyObject *args, PyObject *kwds) { @@ -701,12 +725,15 @@ {"add_done_callback", (PyCFunction)FutureObj_add_done_callback, METH_O, pydoc_add_done_callback}, {"remove_done_callback", (PyCFunction)FutureObj_remove_done_callback, METH_O, pydoc_remove_done_callback}, + {"_schedule_callbacks", + (PyCFunction)FutureObj_schedule_callbacks, + METH_NOARGS, pydoc_schedule_callbacks}, {"set_result", (PyCFunction)FutureObj_set_result, METH_O, pydoc_set_result}, {"set_exception", (PyCFunction)FutureObj_set_exception, METH_O, pydoc_set_exception}, {"cancel", (PyCFunction)FutureObj_cancel, METH_NOARGS, pydoc_cancel}, {"cancelled", diff -r 26249f82c15d PCbuild/_asyncio.vcxproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PCbuild/_asyncio.vcxproj Tue Oct 18 03:18:42 2016 +0900 @@ -0,0 +1,77 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + PGInstrument + Win32 + + + PGInstrument + x64 + + + PGUpdate + Win32 + + + PGUpdate + x64 + + + Release + Win32 + + + Release + x64 + + + + {384C224A-7474-476E-A01B-750EA7DE918C} + _asyncio + Win32Proj + + + + + DynamicLibrary + NotSet + + + + .pyd + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + + + + + + + + + + {cf7ac3d1-e2df-41d2-bea6-1e2556cdea26} + false + + + + + + diff -r 26249f82c15d PCbuild/_asyncio.vcxproj.filters --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PCbuild/_asyncio.vcxproj.filters Tue Oct 18 03:18:42 2016 +0900 @@ -0,0 +1,16 @@ + + + + + + + + {2422278e-eeeb-4241-8182-433e2bc5a7fc} + + + + + Source Files + + + \ No newline at end of file diff -r 26249f82c15d PCbuild/pcbuild.proj --- a/PCbuild/pcbuild.proj Mon Oct 17 18:13:46 2016 +0200 +++ b/PCbuild/pcbuild.proj Tue Oct 18 03:18:42 2016 +0900 @@ -48,13 +48,13 @@ - + diff -r 26249f82c15d PCbuild/pcbuild.sln --- a/PCbuild/pcbuild.sln Mon Oct 17 18:13:46 2016 +0200 +++ b/PCbuild/pcbuild.sln Tue Oct 18 03:18:42 2016 +0900 @@ -91,12 +91,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssleay", "ssleay.vcxproj", "{10615B24-73BF-4EFA-93AA-236916321317}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pyshellext", "pyshellext.vcxproj", "{0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_testconsole", "_testconsole.vcxproj", "{B244E787-C445-441C-BDF4-5A4F1A3A1E51}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_asyncio", "_asyncio.vcxproj", "{384C224A-7474-476E-A01B-750EA7DE918C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 PGInstrument|Win32 = PGInstrument|Win32 PGInstrument|x64 = PGInstrument|x64 diff -r 26249f82c15d PCbuild/pythoncore.vcxproj --- a/PCbuild/pythoncore.vcxproj Mon Oct 17 18:13:46 2016 +0200 +++ b/PCbuild/pythoncore.vcxproj Tue Oct 18 03:18:42 2016 +0900 @@ -210,13 +210,12 @@ -