Subject | Hash | Author | Date (UTC) |
---|---|---|---|
bpo-30048: asyncio: fix Task.cancel() was ignored. (GH-1097) | 991adca012f5e106c2d4040ce619c696ba6f9c46 | INADA Naoki | 2017-05-11 12:18:38 |
#30190: fix invalid escape sequence warnings (#1534) | c4750959acbfc3057f12aaec832483ba30898d1c | Giampaolo Rodola | 2017-05-10 18:13:20 |
bpo-28787: Fix out of tree --with-dtrace builds (#135) | f6eae5bf1c5d7b83e5d5bdbecfff928e478c1cfd | stratakis | 2017-05-10 15:08:15 |
bpo-30281: Fix the default value for stop in PySlice_Unpack() (#1480) | 2ddf5a19c3a06978edff2c8ba0aaf5df3528204a | Xiang Zhang | 2017-05-10 10:19:41 |
bpo-30298: Weaken the condition of deprecation warnings for inline modifiers. (#1490) | 305ccbe27ea5ba82fd2d8c32ec739f980e524330 | Serhiy Storchaka | 2017-05-10 03:05:20 |
bpo-30320: test_eintr now uses pthread_sigmask() (#1523) | 211a392cc15f9a7b1b8ce65d8f6c9f8237d1b77f | Victor Stinner | 2017-05-10 00:37:42 |
PCbuild/build.bat: pass command line parameters when building PGO (#1510) | 291557e2904fa149ee3d56142f41acf63c47fea3 | Charles | 2017-05-09 21:58:48 |
bpo-30285: Optimize case-insensitive matching and searching (#1482) | 6d336a027913327fc042b0d758a16724fea27b9c | Serhiy Storchaka | 2017-05-09 20:37:14 |
bpo-30024: Circular imports involving absolute imports with binding (#1264) | f93234bb8a87855f295d441524e519481ce6ab13 | Serhiy Storchaka | 2017-05-09 19:31:05 |
bpo-30273: update distutils.sysconfig for venv's created from Python (#1515) | dbdea629e2e0e4bd8845aa55041e0a0ca4172cf3 | Jeremy Kloth | 2017-05-09 15:24:13 |
bpo-30258: regrtest: Fix run_tests_multiprocess() (#1479) | 74683fc6247c522ae955a6e7308b8ff51def35d8 | Victor Stinner | 2017-05-09 09:34:01 |
bpo-29990: Fix range checking in GB18030 decoder (#1495) | 9da408d15bdef624a5632182cb4edf98001fa82f | Xiang Zhang | 2017-05-09 03:38:32 |
bpo-30289: remove Misc/python-config.sh when make distclean (#1498) | fa5abac1e6cd74979557d5a6f960a55f40a10b0e | Xiang Zhang | 2017-05-09 02:32:13 |
bpo-29979: Rewrite cgi.parse_multipart to make it consistent with FieldStorage (#991) | cc3fa204d357be5fafc10eb8c2a80fe0bca998f1 | Pierre Quentel | 2017-05-08 12:08:34 |
Fix a trivial typo in global section (#1497) | f34c6850203a2406c4950af7a9c8a134145df4ea | Jim Fasarakis-Hilliard | 2017-05-08 11:36:29 |
Closes bpo-30168: indent methods in Logger Class (#1295) | 55ace65eba587fe3cf3759a43cccf85214651971 | Jim Fasarakis-Hilliard | 2017-05-07 18:40:18 |
Revert bpo-26293 for zipfile breakage. See also bpo-29094. (#1484) | 3763ea865cee5bbabcce11cd577811135e0fc747 | Serhiy Storchaka | 2017-05-06 11:46:01 |
bpo-30218: support path-like objects in shutil.unpack_archive() (GH-1367) | a12df7b7d40dbf47825917c8fa03d2c09b5a382c | Jelle Zijlstra | 2017-05-05 21:27:12 |
bpo-29243: Fix Makefile with respect to --enable-optimizations (#1478) | a1054c3b0037d4c2a5492e79fc193f36245366c7 | torsava | 2017-05-05 15:35:50 |
bpo-29920: Document cgitb.text() and cgitb.html() functions (GH-849) | c07b3a15be5e0a68a73b4c532861ed8de6932bd2 | masklinn | 2017-05-05 08:15:12 |
File | Lines added | Lines deleted |
---|---|---|
Lib/asyncio/tasks.py | 6 | 1 |
Lib/test/test_asyncio/test_tasks.py | 18 | 0 |
Misc/NEWS | 3 | 0 |
Modules/_asynciomodule.c | 12 | 0 |
File Lib/asyncio/tasks.py changed (mode: 100644) (index 4fbcf3ed2e..e4533000e7) | |||
... | ... | class Task(futures.Future): | |
176 | 176 | else: | else: |
177 | 177 | result = coro.throw(exc) | result = coro.throw(exc) |
178 | 178 | except StopIteration as exc: | except StopIteration as exc: |
179 | self.set_result(exc.value) | ||
179 | if self._must_cancel: | ||
180 | # Task is cancelled right before coro stops. | ||
181 | self._must_cancel = False | ||
182 | self.set_exception(futures.CancelledError()) | ||
183 | else: | ||
184 | self.set_result(exc.value) | ||
180 | 185 | except futures.CancelledError: | except futures.CancelledError: |
181 | 186 | super().cancel() # I.e., Future.cancel(self). | super().cancel() # I.e., Future.cancel(self). |
182 | 187 | except Exception as exc: | except Exception as exc: |
File Lib/test/test_asyncio/test_tasks.py changed (mode: 100644) (index 754a67519b..988b2885c3) | |||
... | ... | class BaseTaskTests: | |
587 | 587 | self.assertFalse(t._must_cancel) # White-box test. | self.assertFalse(t._must_cancel) # White-box test. |
588 | 588 | self.assertFalse(t.cancel()) | self.assertFalse(t.cancel()) |
589 | 589 | ||
590 | def test_cancel_at_end(self): | ||
591 | """coroutine end right after task is cancelled""" | ||
592 | loop = asyncio.new_event_loop() | ||
593 | self.set_event_loop(loop) | ||
594 | |||
595 | @asyncio.coroutine | ||
596 | def task(): | ||
597 | t.cancel() | ||
598 | self.assertTrue(t._must_cancel) # White-box test. | ||
599 | return 12 | ||
600 | |||
601 | t = self.new_task(loop, task()) | ||
602 | self.assertRaises( | ||
603 | asyncio.CancelledError, loop.run_until_complete, t) | ||
604 | self.assertTrue(t.done()) | ||
605 | self.assertFalse(t._must_cancel) # White-box test. | ||
606 | self.assertFalse(t.cancel()) | ||
607 | |||
590 | 608 | def test_stop_while_run_in_complete(self): | def test_stop_while_run_in_complete(self): |
591 | 609 | ||
592 | 610 | def gen(): | def gen(): |
File Misc/NEWS changed (mode: 100644) (index 5ee7ea65ff..4e17a66bd9) | |||
... | ... | Extension Modules | |
320 | 320 | Library | Library |
321 | 321 | ------- | ------- |
322 | 322 | ||
323 | - bpo-30048: Fixed ``Task.cancel()`` can be ignored when the task is | ||
324 | running coroutine and the coroutine returned without any more ``await``. | ||
325 | |||
323 | 326 | - bpo-30298: Weaken the condition of deprecation warnings for inline modifiers. | - bpo-30298: Weaken the condition of deprecation warnings for inline modifiers. |
324 | 327 | Now allowed several subsequential inline modifiers at the start of the | Now allowed several subsequential inline modifiers at the start of the |
325 | 328 | pattern (e.g. ``'(?i)(?s)...'``). In verbose mode whitespaces and comments | pattern (e.g. ``'(?i)(?s)...'``). In verbose mode whitespaces and comments |
File Modules/_asynciomodule.c changed (mode: 100644) (index e902c041e5..150ca198d2) | |||
... | ... | task_step_impl(TaskObj *task, PyObject *exc) | |
1985 | 1985 | if (_PyGen_FetchStopIterationValue(&o) == 0) { | if (_PyGen_FetchStopIterationValue(&o) == 0) { |
1986 | 1986 | /* The error is StopIteration and that means that | /* The error is StopIteration and that means that |
1987 | 1987 | the underlying coroutine has resolved */ | the underlying coroutine has resolved */ |
1988 | if (task->task_must_cancel) { | ||
1989 | // Task is cancelled right before coro stops. | ||
1990 | Py_DECREF(o); | ||
1991 | task->task_must_cancel = 0; | ||
1992 | et = asyncio_CancelledError; | ||
1993 | Py_INCREF(et); | ||
1994 | ev = NULL; | ||
1995 | tb = NULL; | ||
1996 | goto set_exception; | ||
1997 | } | ||
1988 | 1998 | PyObject *res = future_set_result((FutureObj*)task, o); | PyObject *res = future_set_result((FutureObj*)task, o); |
1989 | 1999 | Py_DECREF(o); | Py_DECREF(o); |
1990 | 2000 | if (res == NULL) { | if (res == NULL) { |
... | ... | task_step_impl(TaskObj *task, PyObject *exc) | |
2002 | 2012 | ||
2003 | 2013 | /* Some other exception; pop it and call Task.set_exception() */ | /* Some other exception; pop it and call Task.set_exception() */ |
2004 | 2014 | PyErr_Fetch(&et, &ev, &tb); | PyErr_Fetch(&et, &ev, &tb); |
2015 | |||
2016 | set_exception: | ||
2005 | 2017 | assert(et); | assert(et); |
2006 | 2018 | if (!ev || !PyObject_TypeCheck(ev, (PyTypeObject *) et)) { | if (!ev || !PyObject_TypeCheck(ev, (PyTypeObject *) et)) { |
2007 | 2019 | PyErr_NormalizeException(&et, &ev, &tb); | PyErr_NormalizeException(&et, &ev, &tb); |