Skip to content

Instantly share code, notes, and snippets.

@flyer103
Last active December 31, 2015 00:08
Show Gist options
  • Save flyer103/7904968 to your computer and use it in GitHub Desktop.
Save flyer103/7904968 to your computer and use it in GitHub Desktop.
test exception
#!/usr/bin/env python2.7
#coding: utf-8
import logging
import gevent
logging.basicConfig(level=logging.INFO)
class TestgException(object):
def run(self):
gwin = gevent.spawn(self._win)
gfail = gevent.spawn(self._fail)
gevent.joinall([gwin, gfail])
print('win ready? %r' % (gwin.ready(),))
print('fail ready? %r' % (gfail.ready(),))
print('win successful()? %r' % (gwin.successful(),))
print('fail successful()? %r' % (gfail.successful(),))
print('exception: %r' % (gfail.exception,))
def _win(self):
return 'you win'
def _fail(self):
raise Exception('you fail')
if __name__ == '__main__':
test = TestgException()
test.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment