[Bf-python] blender and external editors - workflow?
Marc Weber
marco-oweber at gmx.de
Fri Aug 20 15:57:24 CEST 2010
Excerpts from Marc Weber's message of Fri Aug 20 14:30:08 +0200 2010:
> Excerpts from Marc Weber's message of Fri Aug 20 09:20:20 +0200 2010:
> > File "/home/marc/mwr/vim-addon-blender-scripting/blender_server.py", line 59, in blenderServer
> > sys.exit(1)
> > SystemExit: 1
>
> This was caused by a sys.exit() call I forgot to remove. So not using a
> background thread works fine now.
> Don't ask me why it popped up whenever you typed *any* line.
> Maybe the error is not cleared by blender if was caused in a thread (?)
>
>
> What could be the reason that context.scene has type NoType?
>
> I tracked it down:
> after s.accept
> context.scene (which was imported by from bpy import context) is gone
>
> print("in thread 2 "+str(type(context.scene)))
> try:
> # receive requests loop:
> while True:
> conn, addr = s.accept()
> print("in thread 3 "+str(type(context.scene)))
>
> Everything is working fine but this small detail?
>
> scene is only set to NoneType if s.socket is called in a thread
Adding this loop to script running it within a Python thread shows that
the scene stat changes from scene object to NonType after 1389
iterations.
while True:
print(str(type(context.scene))+str(n))
n = n +1
It also makes blender segfault.
Also adding a timer shows that the scene is present sometimes and
sometimes not:
t = timeit.Timer()
try:
n = 1
while True:
print(str(type(context.scene))+str(n)," ",t.timeit())
n = n +1
first number is iteration step, the second is timing.
<class 'bpy.types.Scene'>1 0.0226609706879
<class 'NoneType'>2 0.0202839374542
<class 'NoneType'>74 0.0213420391083
<class 'bpy.types.Scene'>75 0.0255241394043
<class 'bpy.types.Scene'>78 0.0206708908081
<class 'NoneType'>79 0.0207800865173
<class 'NoneType'>2548 0.029464006424
<class 'bpy.types.Scene'>2549 0.0397069454193
<class 'bpy.types.Scene'>2551 0.0279560089111
<class 'NoneType'>2552 0.0205199718475
So is scene only attached when a python script is evaluated?
Marc Weber
More information about the Bf-python
mailing list