Clean up poll API and handle waiting for `when` promise to resolve.
Clean up poll API and handle waiting for `when` promise to resolve.

jupyter/jupyterlab,jupyter/jupyterlab,jupyter/jupyterlab,jupyter/jupyterlab,jupyter/jupyterlab