[issue22239] asyncio: nested event loop
Daniel Arbuckle added the comment: All right. However, for anyone who's interested, here is a patch that enables nested event loops in asyncio, and the accompanying unit tests -- keywords: +patch Added file: http://bugs.python.org/file36498/nested.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22239 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22239] asyncio: nested event loop
New submission from Daniel Arbuckle: It's occasionally necessary to invoke the asyncio event loop from code that was itself invoked within (although usually not directly by) the event loop. For example, imagine you are writing a class that serves as a local proxy for a remote data structure. You can not make the __contains__ method of that class into a coroutine, because Python automatically converts the return value into a boolean. However, __contains__ must invoke coroutines in order to communicate over the network, and it must be invokable from within a coroutine to be at all useful. If the event loop _run_once method were reentrant, addressing this problem would be simple. That primitive could be used to create a loop_until_complete function, which could be applied to the io tasks that __contains__ needs to invoke So, making _run_once reentrant is one way of addressing this request. Alternately, I've attached a decorator that sets aside some of the state of _run_once, runs a couroutine to completion in a nested event loop, restores the saved state, and returns the coroutine's result. This is merely a proof of concept, but it does work, at least in my experiments. -- components: asyncio files: nested.py messages: 225578 nosy: djarb, gvanrossum, haypo, yselivanov priority: normal severity: normal status: open title: asyncio: nested event loop type: enhancement Added file: http://bugs.python.org/file36422/nested.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22239 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1563] asyncore and asynchat incompatible with Py3k str and bytes
Daniel Arbuckle [EMAIL PROTECTED] added the comment: From what I understand, the OP wants to be able to pass unicode strings across a network connection. That's incorrect. At the time I formulated this patch, asyncore/asynchat were slated for removal from the standard lib unless somebody stepped up and made it work correctly after the str/bytes transition. That's what asyn_py3k.diff and its predecessors do, as well as adding sorely-needed docstrings to the module. This patch may be a little more complete than the currently committed code, or it may be largely redundant. The docstrings, at least, are still needed. The asyn_py3k_restructured.diff patch is a superset of asyn_py3k.diff, which additionally removes the producer type from the module, replacing it with iterators. This is controversial, and seems unlikely to be committed. ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue1563 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1563] asyncore and asynchat incompatible with Py3k str and bytes
Daniel Arbuckle [EMAIL PROTECTED] added the comment: As of December 2007, Guido did not believe that you or anyone else cared enough about asyncore/asynchat to update them to py3k: http://mail.python.org/pipermail/python-dev/2007-December/075574.html Thankfully there's been a resurgence of activity on the modules, and they're well out of danger now. I _am_not_ proposing that passing unicode into asyncore should do anything other than fail. I have never proposed such, and my patch tightened those constraints rather than loosening them. Please stop beating that horse; it's dead. On a more positive note, I'll put together that docstring patch for you at the same time I'm evaluating whether any of the rest of my patch remains necessary. ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue1563 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1563] asyncore and asynchat incompatible with Py3k str and bytes
Daniel Arbuckle [EMAIL PROTECTED] added the comment: I'll update the patch and post it again. ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue1563 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1641] asyncore delayed calls feature
Daniel Arbuckle [EMAIL PROTECTED] added the comment: Unfortunately, it appears that asyncore and asynchat are caught in a deadlock, in which it is demanded that certain patches be applied before any further work is done, but nobody (even among those making the demands) is both willing and able to review and apply those patches. We need this situation to be resolved, preferably by somebody with commit access doing the necessary work, but failing that by allowing new patches and requiring the old ones to be updated at whatever time somebody decides to actually address them. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1641 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1736190] asyncore/asynchat patches
Changes by Daniel Arbuckle: -- nosy: +djarb _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1736190 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1563] asyncore and asynchat incompatible with Py3k str and bytes
Changes by Daniel Arbuckle: Added file: http://bugs.python.org/file9428/asyn_py3k_restructured.diff __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1563 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1563] asyncore and asynchat incompatible with Py3k str and bytes
Changes by Daniel Arbuckle: Added file: http://bugs.python.org/file9427/asyn_py3k.diff __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1563 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1641] asyncore delayed calls feature
Changes by Daniel Arbuckle: -- nosy: +djarb __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1641 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com