code: def connect():
  	
  	if not is_notebook():
  		print('Python session is not running in a Notebook Kernel')
  		return
  	
  	global _comm
  
  	kernel=get_ipython().kernel
  	kernel.comm_manager.register_target('tdb',handle_comm_opened)
  	# initiate connection to frontend.
  	_comm=Comm(target_name='tdb',data={})
  	# bind recv handler
  	_comm.on_msg(None)
docs: establish connection to frontend notebook