         if @state != 'loading'
             cb("init_dom BUG: @state must be loading")
             return
+        @_init_dom_timeout ?= 3
+        @_init_dom_timeout = Math.min(1.5*@_init_dom_timeout, 20)
         @notebook.css('opacity',0)  # invisible, so you don't see a funny half-loaded notebook (from the file rather than the syncstring), before monkey patching.
         done = (err) =>
             @notebook.css('opacity',1)

underscore = require('underscore')

class JupyterWrapper extends EventEmitter
    constructor: (@element, @server_url, @filename, @read_only, @project_id, cb) ->
        @blobs = {}
        @blobs_pending = {}
        @state = 'loading'

                    @emit('ready')
                    cb()
                else
                    console.log 'Jupyter -- not yet fully connected'
                    setTimeout(f, 1000)
        f()

    dbg: (f) =>
