#NEWLINE# @ gen . coroutine #NEWLINE# def start( self , image = None ) : #NEWLINE# #INDENT# 'start the single-user server in a docker container' #NEWLINE# self . _user_log = [ ] #NEWLINE# self . _is_failed = False #NEWLINE# self . _is_building = True #NEWLINE# try : #NEWLINE# #INDENT# f = self . build_image ( ) #NEWLINE# image_name = ( yield gen . with_timeout ( timedelta ( seconds = self . start_timeout ) , f ) ) #NEWLINE# self . _is_building = False #NEWLINE# self . log . info ( ( 'Starting container from image: %s' % image_name ) ) #NEWLINE# self . _add_to_log ( 'Creating container' ) #NEWLINE# ( yield super ( CustomDockerSpawner , self ) . start ( image = image_name ) ) #NEWLINE# self . _add_to_log ( 'Adding to proxy' ) #NEWLINE# #UNINDENT# except gen . TimeoutError : #NEWLINE# #INDENT# self . _is_failed = True #NEWLINE# if self . _cur_waiter : #NEWLINE# #INDENT# self . _user_log . extend ( self . _cur_waiter . building_log ) #NEWLINE# self . _cur_waiter . timeout_happened ( ) #NEWLINE# #UNINDENT# self . _is_building = False #NEWLINE# self . _add_to_log ( ( 'Building took too long (> %.3f secs)' % self . start_timeout ) , level = 2 ) #NEWLINE# raise #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# self . _is_failed = True #NEWLINE# message = str ( e ) #NEWLINE# if message . startswith ( 'Failed to get port' ) : #NEWLINE# #INDENT# message = "Container doesn't have jupyter-singleuser inside" #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'Cannot locate specified Dockerfile' in message ) : #NEWLINE# #INDENT# message = "Your repo doesn't include Dockerfile" #NEWLINE# #UNINDENT# #UNINDENT# self . _add_to_log ( ( 'Something went wrong during building. Error: %s' % message ) ) #NEWLINE# raise e