sockets - Maya crash in Python script -


i'm new python, exploring can't execute program because maya crashes. don't know more. everytime execute python script in script editor have quit maya , restart it, because de program won't respond. code i'm using is:

import socket  import maya.cmds cmds  udp_ip="localhost"  udp_port=6001  sock = socket.socket( socket.af_inet, socket.sock_dgram )  sock.bind((udp_ip, udp_port))  while 1:      data= sock.recv(1024)     print (data)     datasplit=data.split(';')     print (datasplit)      mylist=[]     in range (0, len(datasplit)):         mylist.append(int(datasplit[i]))     print(mylist)      cmds.setattr('ik_root.movex',mylist[0])     cmds.setattr('ik_root.movey',mylist[1])     cmds.setattr('ik_root.movez',mylist[2])       cmds.refresh() 

any help?

the while loop has no exit, you'll stuck in listen-and-process mode forever. call socket.recv blocking, won't able interact maya @ while script running - script grab main ui thread (where mel/python runs) , never let go.

if want run external communications protocol you'll have learn how maya handles python threads ( docs here ). if aren't tied external communications protocol may have better luck using maya's native commandport -- doesn't special except listen on tcp , trigger scripts, @ least means don't need create own threaded client inside of maya. other choices remoting client rpyc , zeromq, both of create client without writing yourself.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -