From 2dba23af7145f3edc608dc16209e6ead38c0f6c8 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 3 Jul 2014 00:59:00 +0200 Subject: asyncio: sync with Tulip * _UnixSubprocessTransport: fix file mode of stdin. Open stdin in write mode, not in read mode * Examples: close the event loop at exit * More reliable CoroWrapper.__del__. If the constructor is interrupted by KeyboardInterrupt or the coroutine objet is destroyed lately, some the _source_traceback attribute doesn't exist anymore. * repr(Task): include also the future the task is waiting for --- Lib/asyncio/coroutines.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'Lib/asyncio/coroutines.py') diff --git a/Lib/asyncio/coroutines.py b/Lib/asyncio/coroutines.py index cdb1ea8d88..71a1ec4dd0 100644 --- a/Lib/asyncio/coroutines.py +++ b/Lib/asyncio/coroutines.py @@ -111,12 +111,14 @@ class CoroWrapper: frame = getattr(gen, 'gi_frame', None) if frame is not None and frame.f_lasti == -1: func = events._format_callback(self.func, ()) - tb = ''.join(traceback.format_list(self._source_traceback)) - message = ('Coroutine %s was never yielded from\n' - 'Coroutine object created at (most recent call last):\n' - '%s' - % (func, tb.rstrip())) - logger.error(message) + msg = 'Coroutine %s was never yielded from' % func + tb = getattr(self, '_source_traceback', ()) + if tb: + tb = ''.join(traceback.format_list(tb)) + msg += ('\nCoroutine object created at ' + '(most recent call last):\n') + msg += tb.rstrip() + logger.error(msg) def coroutine(func): -- cgit v1.2.1