#NEWLINE# def poll( poller , * args , **kwargs ) : #NEWLINE# #INDENT# '\n    Polls a callback (poller) until success is met\n    poller must be a valid callback and returns True on success\n    ' #NEWLINE# timeout = 10 #NEWLINE# if ( 'timeout' in kwargs ) : #NEWLINE# #INDENT# timeout = kwargs [ 'timeout' ] #NEWLINE# kwargs . pop ( 'timeout' ) #NEWLINE# #UNINDENT# success = False #NEWLINE# with gevent . timeout . Timeout ( timeout ) : #NEWLINE# #INDENT# while ( not success ) : #NEWLINE# #INDENT# success = poller ( * success , ** kwargs ) #NEWLINE# gevent . sleep ( 0.2 ) #NEWLINE# #UNINDENT# #UNINDENT# return success