Last active
December 31, 2015 00:08
-
-
Save flyer103/7904968 to your computer and use it in GitHub Desktop.
test exception
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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