Re: [Python-Dev] Python-Dev Digest, Vol 53, Issue 23
"Josiah Carlson"
wrote: On Dec 5, 2007 9:19 AM, Guido van Rossum wrote: The asyncore and asynchat modules are in a difficult position when it comes to Python 3000. None of the core developers use it or particularly care about it (AFAIK), and the API has problems because it wasn't written to deal with bytes vs. unicode. E.g. in http://bugs.python.org/issue1067, Thomas suggests that these modules need to be rewritten to use bytes internally and have separate APIs to handle (unicode) text as desired, similar to the way file I/O was redesigned. Another alternative would be to make these modules deal strictly in bytes, but that would probably vastly reduce their usefulness (though I don't know -- as I said, I don't use them).
I can look into it later this month, but for the short term, I'm a little squeezed for time (work, finishing school, etc.). I am a bit curious, however, I could have sworn that bytes were to become, essentially, the 2.x str type (without some methods). If that is the case, no changes should really be necessary, except for a few small changes to asynchat with regards to line terminators.
Then again, I haven't really been keeping up in the p3k/pydev lists for the last 6-8 months, and only the subject line of this posting caught my eye (because I use asyncore/asynchat, and support users of asyncore/asynchat that contact me directly).
You're exactly right about the (lack of) problems and the correct way to fix them. I've placed a patch in the bug tracker that takes that very approach. http://bugs.python.org/issue1563
Some things I would change in the docstrings:
+ A dispatcher object handles a single socket, processing connect, + accept, close, read and write events as defined by the child + handle_connect, handle_accept, handle_close, handle_read and + handle_write methods, respectively. The child may also define + handle_expt to handle exceptions raised during the communication + process.
handle_expt is used for managing of OOB (Out Of Band) data. The method called when an unhandled exception is raised is dispatcher.handle_error().
+ """Sets the socket.SO_REUSEADDR socket option, is possible
Typo ("IF possible").
def handle_error(self): + """Internal method, do not override."""
I would change into: "Called when an exception is raised and not otherwise handled. The default version prints a condensed traceback.", the same thing reported in the doc.
def handle_expt(self): + """Called to handle an exception event. + + Children may override this method to implement exception + processing. + + """
Like said above, this is called when arrived some OOB data. I would change this into something like: "Called when some OOB data arrived."
On Dec 9, 2007, at 5:52 AM, Giampaolo Rodola' wrote:
def handle_expt(self):
Like said above, this is called when arrived some OOB data. I would change this into something like: "Called when some OOB data arrived."
Of course, that's not actually true. It's called for whatever the exc bit from select indicates, which varies by platform. Oh, and if you're using the "poll2" implementation of asyncore, handle_expt is called only when there's an error on the socket, instead. Ah, wonderful abstraction. James
Mmmmm... This is what asyncore documentation says about handle_expt:
Called when there is out of band (OOB) data for a socket connection. This will almost never happen, as OOB is tenuously supported and rarely used.
So, if you're right, the doc is wrong and should be rewritten.
Or maybe this is just a big mistake: could you please take a look at
Python issue #1541?
On 9 Dic, 17:35, James Y Knight
On Dec 9, 2007, at 5:52 AM, Giampaolo Rodola' wrote:
def handle_expt(self):
Like said above, this is called when arrived some OOB data. I would change this into something like: "Called when some OOB data arrived."
Of course, that's not actually true. It's called for whatever the exc bit from select indicates, which varies by platform. Oh, and if you're using the "poll2" implementation of asyncore, handle_expt is called only when there's an error on the socket, instead. Ah, wonderful abstraction.
James
_______________________________________________ Python-Dev mailing list Python-...@python.orghttp://mail.python.org/mailman/listinfo/python-dev Unsubscribe:http://mail.python.org/mailman/options/python-dev/python-dev2-garchiv...
participants (3)
-
Daniel Arbuckle
-
Giampaolo Rodola'
-
James Y Knight