[Bf-python] bpy api *gotcha's* documented.

HartsAntler goatman.py at gmail.com
Sat Aug 27 12:31:12 CEST 2011


It is safe to use python threads in Blender, and they don't have to stop
when the script exists.

Just when the py thread touches blender data it needs to be threadsafe.
 When its not touching blender data, it can run freely, for example send
some data over a pipe or socket.  And this will help performance since the
sendall on the socket releases the GIL, and won't block blender.

How to make the thread "know" when its safe to touch blender data, you can
use the redraw callback hack, in the future the locking would be better done
with ideasman's new patch that allows for python callbacks on post_depgraph
update.
http://pastebin.com/HgCWmLHh

-brett


On Sat, Aug 27, 2011 at 2:58 AM, Campbell Barton <ideasman42 at gmail.com>wrote:

> Update - added a section on unicode problems
>
>
> http://www.blender.org/documentation/blender_python_api_2_59_0/info_gotcha.html#unicode-problems
>
> On Fri, Aug 26, 2011 at 4:55 PM, bartius crouch
> <bartius.crouch at gmail.com> wrote:
> > Very useful document. People who use the bpy api a lot are probably
> > already aware of these points.
>
> For the basics, sure, But to write the docs I had to do read up on
> python docs and do tests myself to double check the docs were
> accurate, even exposed a few bugs in pythons api including a crash -
> issue IMHO is some parts of the api experienced py devs avoid because
> they give problems but that also means they don't get tested properly
> and new scripters can run into them.
>
> > but I think especially the last part on memory re-allocation is very
> useful for people who are wondering why
> > their script is crashing.
> >
> > Bart
>
> --
> - Campbell
> _______________________________________________
> Bf-python mailing list
> Bf-python at blender.org
> http://lists.blender.org/mailman/listinfo/bf-python
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20110827/7f9c447d/attachment.html>


More information about the Bf-python mailing list