[issue23208] asyncio: add BaseEventLoop._current_handle (only used in debug mode)

2015-01-27 Thread Roundup Robot

Roundup Robot added the comment:

New changeset d61d1e73674f by Victor Stinner in branch '3.4':
asyncio: sync with Tulip
https://hg.python.org/cpython/rev/d61d1e73674f

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23208
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23208] asyncio: add BaseEventLoop._current_handle (only used in debug mode)

2015-01-26 Thread STINNER Victor

STINNER Victor added the comment:

I commited  current_handle.patch. It's only a first step, I will also change 
the logger or calls to the logger to use this traceback of the current handle.

--
resolution:  - fixed
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23208
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23208] asyncio: add BaseEventLoop._current_handle (only used in debug mode)

2015-01-26 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 54d74f954bf9 by Victor Stinner in branch '3.4':
Issue #23208, asyncio: Add BaseEventLoop._current_handle
https://hg.python.org/cpython/rev/54d74f954bf9

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23208
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23208] asyncio: add BaseEventLoop._current_handle (only used in debug mode)

2015-01-20 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@gmail.com:


--
title: asyncio: add BaseEventLoop._current_handle - asyncio: add 
BaseEventLoop._current_handle (only used in debug mode)

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23208
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23208] asyncio: add BaseEventLoop._current_handle

2015-01-20 Thread STINNER Victor

STINNER Victor added the comment:

@Guido, @Yury: What do you think of this feature? Does it make sense to expose 
(internally) the handle currently executed?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23208
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23208] asyncio: add BaseEventLoop._current_handle

2015-01-20 Thread Yury Selivanov

Yury Selivanov added the comment:

 What do you think of this feature? Does it make sense to expose (internally) 
 the handle currently executed?

I think it's OK to have something like `loop._current_handle` to work ~only~ in 
debug mode. Enhancing `loop.call_exception_handler` to use it also makes sense. 
I would also want to make sure, that this property exists only in debug mode 
and shouldn't be used outside of asyncio.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23208
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23208] asyncio: add BaseEventLoop._current_handle

2015-01-09 Thread STINNER Victor

New submission from STINNER Victor:

One pain point of asynchronous programming is to understand bugs and rebuild 
the chain of callbacks / coroutines / tasks. I added the source traceback to 
Handle, Future (Task) and CoroWrapper to help debugging.

Here is a new enhancement to provide more context in debug mode: add 
BaseEventLoop._current_handle which is the handle currently executed.

The first usage is the call_exception_handler() which logs the source traceback 
of the current handle in debug mode.

Example:
---
import asyncio

def bug():
loop.call_exception_handler({'message': 'bug!'})

def schedule_bug():
bug()

loop = asyncio.get_event_loop()
loop.call_soon(schedule_bug)
loop.call_later(1, loop.stop)
loop.run_forever()
loop.close()
---

Output in debug mode, without the patch:
---
bug!
---

Output in debug mode, with the patch:
---
bug!
handle_traceback: Handle created at (most recent call last):
  File x.py, line 10, in module
loop.call_soon(schedule_bug)
---

Later, I plan to use the source traceback of the current handle in more places. 
For example, use it to log messages.

I would like to know who logged the SSL handshake failed. At the beginning, 
I wanted to add a source traceback to all transports, but it looks simpler to 
get the source traceback of the current handler. Moreover, this traceback is 
more useful than the source traceback of the transport.

Previous try to add the source traceback to transports:
https://code.google.com/p/tulip/issues/detail?id=212

--
components: asyncio
files: current_handle.patch
keywords: patch
messages: 233759
nosy: gvanrossum, haypo, yselivanov
priority: normal
severity: normal
status: open
title: asyncio: add BaseEventLoop._current_handle
versions: Python 3.4, Python 3.5
Added file: http://bugs.python.org/file37655/current_handle.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23208
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23208] asyncio: add BaseEventLoop._current_handle

2015-01-09 Thread STINNER Victor

STINNER Victor added the comment:

Yury Selivanov proposed something different in the past: add a context (or a 
context identifier) to tasks to be able to (indirectly) attach local variables 
to tasks.

Add notion of context_id to event loop
https://code.google.com/p/tulip/issues/detail?id=165

I don't know if BaseEventLoop._current_handle is too specific or might be 
implemented with a task context. The task context looks to be specific to 
tasks, whereas handles are very generic in asyncio: almost all functions in 
asyncio are called in the context of a handle.

Previous discussion related to task context:

local context in event loop
https://groups.google.com/forum/#!topic/python-tulip/zix5HQxtElg

ThreadLocal analogue
https://groups.google.com/forum/#!topic/python-tulip/j0cSjUGx8qk

See also the tasklocals project:
https://github.com/vkryachko/tasklocals

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23208
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com