Created
May 25, 2014 23:20
-
-
Save anonymous/5bffe8b16e6f6e7a4618 to your computer and use it in GitHub Desktop.
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
from twisted.internet import defer, reactor | |
import treq | |
count = 0 | |
def TestD(): | |
def handleError( res ): | |
print 'ERROR' | |
def handleResponse( res ): | |
global count | |
count = count + 1 | |
print count | |
if count < 10: | |
d = TestD() | |
d.addCallback( handleResponse ) | |
else: | |
return res | |
d = treq.get('http://0.0.0.0:8081') | |
d.addCallback( handleResponse ) | |
d.addErrback( handleError ) | |
return d | |
def finish(): | |
print 'FINISH' | |
reactor.stop() | |
if __name__=='__main__': | |
d = TestD() | |
d.addCallback(finish) | |
d.addErrback(finish) | |
reactor.run() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment