[issue22875] asyncio: call_soon() documentation unclear on timing

2014-11-14 Thread Corbin Simpson

New submission from Corbin Simpson:

Hi there!

While assisting somebody on #python (where manners go to die), I was consulting 
asyncio's documentation. Given my unfamiliarity with asyncio, I was surprised 
to read BaseEventLoop.call_soon()'s documented behavior: Arrange for a 
callback to be called as soon as possible. [1]

The question in mind is whether call_soon() waits for control to return to the 
event loop before calling the first callback in the queue. After all, given the 
documented behavior, it would not be unreasonable for call_soon() to always 
call callbacks immediately if no other callbacks were enqueued. I can imagine 
scenarios where a previous queued callback from e.g. call_soon_threadsafe() 
creates a callback that causes queueing behavior, but otherwise I would expect 
as soon as possible to mean immediately.

It's true that in other event loops, this kind of callback registration waits 
for control to return to the event loop before running callbacks. However, many 
event loops that I've worked with indicate that call_later() is the correct API 
for adding callbacks that respect the event loop. In fact, call_later(0, 
callback, args) looks quite a bit like the familiar Twisted callLater(0, 
callback, args) pattern!

Additionally, there is no indication as to whether call_later() and call_soon() 
use the same queue.

I'd like clarification on these points in the Python 3 documentation, please. 
I'd like to know whether call_soon() can be immediate, and whether call_soon() 
preempts or interleaves with call_later().

(Yes, I know that Twisted's documentation is missing this too [2] [3]. I'll get 
to that soon enough.)

Thanks!
~ C.

[1]: 
https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.BaseEventLoop.call_soon
[2]: http://twistedmatrix.com/documents/current/core/howto/time.html
[3]: 
http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.IReactorTime.html#callLater

--
assignee: docs@python
components: Documentation, asyncio
messages: 231180
nosy: Corbin.Simpson, docs@python, gvanrossum, haypo, yselivanov
priority: normal
severity: normal
status: open
title: asyncio: call_soon() documentation unclear on timing

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



[issue6442] Backwards __contains__/has_key in xml/sax/xmlreader.py

2009-07-08 Thread Corbin Simpson

New submission from Corbin Simpson mostawesomed...@gmail.com:

Not a big deal, but these two methods were backwards in AttributesImpl
in xml/sax/xmlreader.py, and it was causing fun little problems in some
of my code on Python 2.6.0, so I decided to whip up a patch.

(Of course, this is fixed in Py3k since has_key() got nuked.)

~ C.

--
components: Library (Lib)
files: temp.patch
keywords: patch
messages: 90290
nosy: MostAwesomeDude
severity: normal
status: open
title: Backwards __contains__/has_key in xml/sax/xmlreader.py
type: behavior
versions: Python 2.6
Added file: http://bugs.python.org/file14475/temp.patch

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