[Python-ideas] asyncore: included batteries don't fit

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Oct 10 09:53:04 CEST 2012

Guido van Rossum wrote:
> But there are
> still quite a few situations in NDB where an uncaught
> exception prints a baffling traceback, showing lots of frames from the
> event loop and other async machinery but not the user code that was
> actually waiting for anything.

I just tried an experiment using Python 3.3. I modified the
parse_request() function of my spamserver example to raise
an exception that isn't caught anywhere:

def parse_request(line):
   tokens = line.split()
   if tokens and tokens[0] == b"EGGS":
     raise ValueError("Server is allergic to eggs")

The resulting traceback looks like this. The last two lines
show very clearly where abouts the exception occurred in
user code. So it all seems to work quite happily.

Traceback (most recent call last):
   File "spamserver.py", line 73, in <module>
"/Local/Projects/D/Python/YieldFrom/3.3/Examples/Scheduler/scheduler.py", line 
109, in run2
"/Local/Projects/D/Python/YieldFrom/3.3/Examples/Scheduler/scheduler.py", line 
53, in run
   File "spamserver.py", line 50, in handler
     n = parse_request(line)
   File "spamserver.py", line 61, in parse_request
     raise ValueError("Server is allergic to eggs")
ValueError: Server is allergic to eggs


More information about the Python-ideas mailing list