surfly/gevent — pull request #266 by schmir (2013-04-06 19:48:24+00:00)
Title: allow to silence error reporting for certain 'expected exceptions'

gevent prints a error report including a traceback for each failed
greenlet. this is at times useful, but you're currently forced to
either handle exceptions in those greenlets or live with the traceback
on stderr.

this change introduces a class variable 'expected_exceptions' to
gevent's greenlet class. This is a tuple of exceptions for which no
error report should be printed to stderr.

This can be set in a custom greenlet subclass, or even at runtime like
in:

,----
| from gevent import spawn, getcurrent
|
| def divide():
| getcurrent().expected_exceptions += (ZeroDivisionError,)
| 1/0
|
| spawn(divide).join()
`----