message: brings back socketio.start_background_task to fix blocked socketio
diff: @@ -27,6 +27,8 @@ from opentrons.server.process_manager import run_once
  TEMPLATES_FOLDER = os.path.join(helpers.get_frozen_root() or '', 'templates')
  STATIC_FOLDER = os.path.join(helpers.get_frozen_root() or '', 'templates')
  +BACKGROUND_TASKS = {}
  +
  exit_threads = threading.Event()
  exit_threads.clear()
  @@ -498,6 +500,39 @@ def connectRobot():
  })
  +def _start_connection_watcher():
  + robot = Robot.get_instance()
  + connection_state_watcher, watcher_should_run = BACKGROUND_TASKS.get(
  + 'CONNECTION_STATE_WATCHER',
  + (None, None)
  + )
  +
  + if connection_state_watcher and watcher_should_run:
  + watcher_should_run.set()
  +
  + watcher_should_run = threading.Event()
  +
  + def watch_connection_state(should_run):
  + while not should_run.is_set():
  + socketio.emit(
  + 'event',
  + {
  + 'type': 'connection_status',
  + 'is_connected': robot.is_connected()
  + }
  + )
  + socketio.sleep(1.5)
  +
  + connection_state_watcher = socketio.start_background_task(
  + watch_connection_state,
  + (watcher_should_run)
  + )
  + BACKGROUND_TASKS['CONNECTION_STATE_WATCHER'] = (
  + connection_state_watcher,
  + watcher_should_run
  + )
  +
  +
  @app.route("/robot/serial/disconnect")
  def disconnectRobot():
  status = 'success'
  @@ -1051,6 +1086,7 @@ def start():
  IS_DEBUG = os.environ.get('DEBUG', '').lower() == 'true'
  if not IS_DEBUG:
  run_once(data_dir)
  + _start_connection_watcher()
  from opentrons.server import log # NOQA
  lg = logging.getLogger('opentrons-app')
  