# How to check a json file dynamically with blender?

I have a json file that is dynamically generated on a server. I'm currently using a python program to copy it locally. I have a script that can check the json file from blender, and change my object rotation, but I can't seem to make it work periodically (like, I'd like the script to run every 0.2 sec).

import json
import bpy
import time

def doit():
with open('/somepath/blendjson.json') as data_file:

coordx = float(data['coordx'])/5
coordy = float(data['coordy'])/5

bpy.ops.transform.rotate(value=coordx, axis=(-1, -0, -0), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1)

bpy.ops.transform.rotate(value=coordy, axis=(-0, -1, -0), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1)

while True:
doit()
time.sleep(0.2)


This script doesn't do anything in blender. When I kill it in the terminal, it throws an empty error, with nothing following it : "Error: Python script fail, look in the console for now..."

The issue here seems to be that time.sleep blocks the script. I can only see the results when I kill it.

I'm looking for an alternative to time.sleep that does not stop the script. I want to run the def every 200 ms, and see the result in real time.

• The time.sleep(0.2) works with a simple print("test") instruction inside of the def. – Guillaume de Maleprade Mar 11 '18 at 12:18
• So, did you look in the console? – Ray Mairlot Mar 11 '18 at 12:35
• As I said, I looked into the terminal, where the error should appear, and it only told me to look in the console. I generally look there to look for the errors I get. – Guillaume de Maleprade Mar 11 '18 at 12:37