1919
2020_scope_flags_ = ("plotlyjs" , "mathjax" , "topojson" , "mapbox_access_token" )
2121
22- def to_image_block (spec , f = None , topojson = None , mapbox_token = None , debug = None ):
22+ def to_image_block (spec , f = None , topojson = None , mapbox_token = None , debug = None , tmp_path = None ):
2323 if debug is None :
2424 debug = "KALEIDO-DEBUG" in os .environ or "KALEIDO_DEBUG" in os .environ
2525 try :
@@ -30,7 +30,7 @@ def to_image_block(spec, f=None, topojson=None, mapbox_token=None, debug=None):
3030 def get_image ():
3131 nonlocal image
3232 if debug : print ("Calling to_image in thread" , file = sys .stderr )
33- image = asyncio .run (to_image (spec , f , topojson , mapbox_token , debug = debug ))
33+ image = asyncio .run (to_image (spec , f , topojson , mapbox_token , debug = debug , tmp_path = tmp_path ))
3434 t = Thread (target = get_image )
3535 if debug : print ("Calling thread start" , file = sys .stderr )
3636 t .start ()
@@ -40,17 +40,17 @@ def get_image():
4040 except RuntimeError :
4141 if debug : print ("No loop, no thread" , file = sys .stderr )
4242 pass
43- return asyncio .run (to_image (spec , f , topojson , mapbox_token , debug = debug ,))
43+ return asyncio .run (to_image (spec , f , topojson , mapbox_token , debug = debug , tmp_path = tmp_path ))
4444
45- async def to_image (spec , f = None , topojson = None , mapbox_token = None , debug = None , timeout = 60 ):
45+ async def to_image (spec , f = None , topojson = None , mapbox_token = None , debug = None , timeout = 60 , tmp_path = None ):
4646 if debug is None :
4747 debug = "KALEIDO-DEBUG" in os .environ or "KALEIDO_DEBUG" in os .environ
4848 def check_error (res ):
4949 if 'error' in res :
5050 raise RuntimeError (str (res ))
5151
5252 async with (
53- Browser (headless = True , debug = debug , debug_browser = debug ) as browser ,
53+ Browser (headless = True , debug = debug , debug_browser = debug , tmp_path = tmp_path ) as browser ,
5454 atimeout .timeout (timeout )):
5555 async def print_all (r ):
5656 print (f"All subscription: { r } " , file = sys .stderr )
0 commit comments