How to save Multiple images via

I try to implement a botton in my Panel Dashboard to save multiple rasterized colormaps as images, depending on the selections. It works fine but the the function does not wait for loading respectively rastering images wich is why the saved .png images are pixelated. I tried the time.sleep() function but it did not fix the issue. My approach is like this (this works because its not rasterized):

import holoviews as hv
import numpy as np
import panel as pn
import param


images = {}
images['img_1'] = hv.Image(np.random.rand(100, 100), bounds=(-10e5, -10e5, 10e5, 10e5))
images['img_2'] = hv.Image(np.random.rand(50, 50), bounds=(-10e5, -10e5, 10e5, 10e5))
images['img_3'] = hv.Image(np.random.rand(700, 700), bounds=(-10e5, -10e5, 10e5, 10e5))

class Plot(param.Parameterized):
    plot_select = param.ObjectSelector(default=[*images][0],objects = [*images])
    @param.depends('plot_select', watch=True)
    def plot(self):
        tile = hv.element.tiles.Wikipedia()
        i = tile*images[self.plot_select]
        return i
view = Plot()
widget = pn.Param(view.param, widgets={'plot_select':{'type':pn.widgets.Select, 'name':'select'}},       parameters=['plot_select'])

def save_figs(event):    
    tile = hv.element.tiles.Wikipedia()
    for img in [*images]:
        out = tile*images[img], fmt='png', filename=img)
download_figs = pn.widgets.Button(name='report figs', button_type = 'primary')

pn.serve(pn.Row(view.plot, widget, download_figs))

Is their a statement for the python cernel to wait for loading?

Hi everybody,
until know I wasn’t able to find a solution for my problem. So I come back to this post. The function does not wait for the rasterized DynamicMap. Therefor the saved png files are pixalated. Does anyone has an idea how I can motive the or the looping to wait for rasterizing the DynamicMap?

The method I try to optimize is the following. It’s embeded in a parameterized class an triggered by another method that works as callback for a pn.widget.FileDownload.

def tri_all_dchg(self):

    for d in self.param['dchg'].objects:
        trimesh = dict_data[self.area][d][self.dict_abs_rel_corr[self.sel_abs_rel]][self.variable].opts(xaxis=None, yaxis=None, width=800, height=500,
                                                        cmap=self.cmap, color_levels= None, clim=self.color_lims()[self.dict_abs_rel_corr[self.sel_abs_rel]][self.variable],
                                                        colorbar=True, colorbar_opts={'title':self.dict_clabel[self.variable]},
                                                        colorbar_position='bottom', tools=['save', self.hovertool()],
                                                        title= self.variable + ' bei einem Abfluss von ' + d +' %',
                                                        fontsize={'ticks': '10pt', 'title': '15pt', 'ylabel': '15pt', 'xlabel': '15pt'})
        x=hv.Dimension('x', range=tuple(self.range_x.x_range)), 
        y=hv.Dimension('y', range=tuple(self.range_y.y_range)))
        out = pn.Row(self.tile()*self.polys()*trimesh*self.fairw_1()*self.fairw_2())
        fig_name = os.path.join('2DHN' + '_' +
                                 self.area + '_' +
                                 self.sel_section+ '_' +
                                 self.variable +
                                 d.replace(' ','_'))
        #time.sleep(20), fmt='png', backend='bokeh')