environment/lib/python2.7/site-packages/IPython/zmq/pylab/backend_inline.py
def flush_figures():
    """Send all figures that changed

    This is meant to be called automatically and will call show() if, during
    prior code execution, there had been any calls to draw_if_interactive.
    
    This function is meant to be used as a post_execute callback in IPython,
    so user-caused errors are handled with showtraceback() instead of being
    allowed to raise.  If this function is not called from within IPython,
    then these exceptions will raise.
    """
    if not show._draw_called:
        return
    
    if InlineBackend.instance().close_figures:
        # ignore the tracking, just draw and close all figures
        try:
            return show(True)
        except Exception as e:
            # safely show traceback if in IPython, else raise
            try:
                get_ipython
            except NameError:
                raise e
            else:
                get_ipython().showtraceback()
                return
    try:
        # exclude any figures that were closed:
        active = set([fm.canvas.figure for fm in Gcf.get_all_fig_managers()])
        for fig in [ fig for fig in show._to_draw if fig in active ]:
            try:
                send_figure(fig)
            except Exception as e:
                # safely show traceback if in IPython, else raise
                try:
                    get_ipython
                except NameError:
                    raise e
                else:
                    get_ipython().showtraceback()
                    break
    finally:
        # clear flags for next round
        show._to_draw = []
        show._draw_called = False
def flush_figures():
    """Send all figures that changed

    This is meant to be called automatically and will call show() if, during
    prior code execution, there had been any calls to draw_if_interactive.
    
    This function is meant to be used as a post_execute callback in IPython,
    so user-caused errors are handled with showtraceback() instead of being
    allowed to raise.  If this function is not called from within IPython,
    then these exceptions will raise.
    """
    if not show._draw_called:
        return
    
    if InlineBackend.instance().close_figures:
        # ignore the tracking, just draw and close all figures
        try:
            return show(True)
        except Exception as e:
            # safely show traceback if in IPython, else raise
            try:
                get_ipython
            except NameError:
                raise e
            else:
                get_ipython().showtraceback()
                return
    try:
        # exclude any figures that were closed:
        active = set([fm.canvas.figure for fm in Gcf.get_all_fig_managers()])
        for fig in [ fig for fig in show._to_draw if fig in active ]:
            try:
                send_figure(fig)
            except Exception as e:
                # safely show traceback if in IPython, else raise
                try:
                    get_ipython
                except NameError:
                    raise e
                else:
                    get_ipython().showtraceback()
                    break
    finally:
        # clear flags for next round
        show._to_draw = []
        show._draw_called = False
Send all figures that changed

    This is meant to be called automatically and will call show() if, during
    prior code execution, there had been any calls to draw_if_interactive.
    
    This function is meant to be used as a post_execute callback in IPython,
    so user-caused errors are handled with showtraceback() instead of being
    allowed to raise.  If this function is not called from within IPython,
    then these exceptions will raise.