From a83636247e3de138e017a04474236ef5aa8b4f4a Mon Sep 17 00:00:00 2001 From: INADA Naoki Date: Fri, 21 Oct 2016 12:30:15 +0900 Subject: Issue #28448: Fix C implemented asyncio.Future didn't work on Windows --- Lib/asyncio/futures.py | 8 ++--- Lib/asyncio/windows_events.py | 9 +++-- Misc/NEWS | 2 ++ PCbuild/_asyncio.vcxproj | 77 ++++++++++++++++++++++++++++++++++++++++ PCbuild/_asyncio.vcxproj.filters | 16 +++++++++ PCbuild/pcbuild.proj | 2 +- PCbuild/pcbuild.sln | 2 ++ PCbuild/pythoncore.vcxproj | 1 - 8 files changed, 109 insertions(+), 8 deletions(-) create mode 100644 PCbuild/_asyncio.vcxproj create mode 100644 PCbuild/_asyncio.vcxproj.filters diff --git a/Lib/asyncio/futures.py b/Lib/asyncio/futures.py index 73215f5..e45d6aa 100644 --- a/Lib/asyncio/futures.py +++ b/Lib/asyncio/futures.py @@ -247,10 +247,10 @@ class Future: if self._state != _PENDING: return False self._state = _CANCELLED - self._schedule_callbacks() + self.__schedule_callbacks() return True - def _schedule_callbacks(self): + def __schedule_callbacks(self): """Internal: Ask the event loop to call all callbacks. The callbacks are scheduled to be called as soon as possible. Also @@ -352,7 +352,7 @@ class Future: raise InvalidStateError('{}: {!r}'.format(self._state, self)) self._result = result self._state = _FINISHED - self._schedule_callbacks() + self.__schedule_callbacks() def set_exception(self, exception): """Mark the future done and set an exception. @@ -369,7 +369,7 @@ class Future: "and cannot be raised into a Future") self._exception = exception self._state = _FINISHED - self._schedule_callbacks() + self.__schedule_callbacks() if compat.PY34: self._log_traceback = True else: diff --git a/Lib/asyncio/windows_events.py b/Lib/asyncio/windows_events.py index 668fe14..b777dd0 100644 --- a/Lib/asyncio/windows_events.py +++ b/Lib/asyncio/windows_events.py @@ -171,8 +171,13 @@ class _WaitCancelFuture(_BaseWaitHandleFuture): def cancel(self): raise RuntimeError("_WaitCancelFuture must not be cancelled") - def _schedule_callbacks(self): - super(_WaitCancelFuture, self)._schedule_callbacks() + def set_result(self, result): + super().set_result(result) + if self._done_callback is not None: + self._done_callback(self) + + def set_exception(self, exception): + super().set_exception(exception) if self._done_callback is not None: self._done_callback(self) diff --git a/Misc/NEWS b/Misc/NEWS index 3760bc7..0ce27de 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -20,6 +20,8 @@ Core and Builtins Library ------- +- Issue #28448: Fix C implemented asyncio.Future didn't work on Windows. + - Issue #28480: Fix error building socket module when multithreading is disabled. diff --git a/PCbuild/_asyncio.vcxproj b/PCbuild/_asyncio.vcxproj new file mode 100644 index 0000000..3cca000 --- /dev/null +++ b/PCbuild/_asyncio.vcxproj @@ -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 --git a/PCbuild/_asyncio.vcxproj.filters b/PCbuild/_asyncio.vcxproj.filters new file mode 100644 index 0000000..10a186c --- /dev/null +++ b/PCbuild/_asyncio.vcxproj.filters @@ -0,0 +1,16 @@ + + + + + + + + {2422278e-eeeb-4241-8182-433e2bc5a7fc} + + + + + Source Files + + + \ No newline at end of file diff --git a/PCbuild/pcbuild.proj b/PCbuild/pcbuild.proj index e26bc70..e0e6e93 100644 --- a/PCbuild/pcbuild.proj +++ b/PCbuild/pcbuild.proj @@ -51,7 +51,7 @@ - + diff --git a/PCbuild/pcbuild.sln b/PCbuild/pcbuild.sln index 7add51e..0e65811 100644 --- a/PCbuild/pcbuild.sln +++ b/PCbuild/pcbuild.sln @@ -94,6 +94,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pyshellext", "pyshellext.vc 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 diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index aa6ba74..769c643 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -213,7 +213,6 @@ - -- cgit v0.12