[Bf-python] Best way for add-on to download with Python

Peter D. Cassetta peter at fingertipsoft.com
Thu Jan 24 03:53:37 CET 2013


Hi everyone,

I've been wondering about this for some time, and considering whether I 
could "build a better mousetrap", so to speak, for my online/offline 
material library add-on. (http://peter.cassetta.info/material-library/)

When being used in online mode, my add-on constantly needs to download 
material previews, materials, textures, OSL shading scripts, etc. Right 
now, performing any action that requires downloading something will 
freeze Blender until it's done. I know that this is the intended 
behavior, but in some cases Blender can be frozen for 10 or more seconds 
until the download is complete, or until the connection times out.

This is clearly not the best way to do things in terms of user 
interaction, and it can make things inefficient for users with a slow 
internet connection. So I've attempted to remedy this (at least in part) 
by caching all downloaded content, but this still requires that the 
content be downloaded in the first place, and is obviously not a 
complete solution.

Some on #blendercoders have suggested using modal operators, which are 
usually helpful for operators which take a long time to run, but they 
are not a solution in my case, because it is not the operator as a whole 
which takes a long time, but rather a single HTTP connection function 
within the operator.

Another suggestion, which I feel would be preferable if I could get it 
working solely or mostly with Python, was to start another process. 
While I'm unsure exactly how one would do this, I got the impression 
that it might be possible to open a separate Python console, or launch 
another Blender instance (preferably in the background), and download 
needed files from there without slowing down anything else in the first 
Blender instance.

Would this be workable, or is there another, better way to do things?
Anyway, I'd appreciate any advice or help people might have to offer.

Many thanks,
Peter Cassetta



More information about the Bf-python mailing list