Message 1 of 1
setSleepCallback in the Python for Maya 2010 MTimerMessage module

Not applicable
09-13-2010
06:15 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hiya, I am trying to add a timer callback to Maya 2010; but, I do not
understand how to set a sleep callback for it so that the timer
callback does not monopolize the CPU. In the python api, I thought all
you would have to do is
import sys
import maya.OpenMaya as OpenMaya
import time
def sleepCallback():
time.sleep(0.5)
def timerCallback(elapsedTime, lastTime, clientData):
sys.stdout.write('test\n')
sys.stdout.flush()
OpenMaya.MTimerMessage.setRegisteringCallableScript()
status = OpenMaya.MTimerMessage.setSleepCallback(sleepCallback)
id = OpenMaya.MTimerMessage.addTimerCallback(0.1, timerCallback, "")
But, I get the following error
# Error: TypeError: in method 'MTimerMessage_setSleepCallback',
argument 1 of type 'MTimerMessage::sleepCallbackPtr' #
This is a problem as I do not see sleepCallbackPtr available in
MTimerMessage.
dir(OpenMaya.MTimerMessage)
# Result: #
This is a none issue with the new MTimerMessage::addTimerCallback()
modification in 2011:
MTimerMessage::addTimerCallback() has been modified such that it no longer requires that Maya's idle queue run continuously. As such, the sleepCallback() and setSleepCallback() methods are no longer needed.
But, I need it to run in both 2010 and 2011. What am I not getting
here?
Thanks,
Ryan
understand how to set a sleep callback for it so that the timer
callback does not monopolize the CPU. In the python api, I thought all
you would have to do is
import sys
import maya.OpenMaya as OpenMaya
import time
def sleepCallback():
time.sleep(0.5)
def timerCallback(elapsedTime, lastTime, clientData):
sys.stdout.write('test\n')
sys.stdout.flush()
OpenMaya.MTimerMessage.setRegisteringCallableScript()
status = OpenMaya.MTimerMessage.setSleepCallback(sleepCallback)
id = OpenMaya.MTimerMessage.addTimerCallback(0.1, timerCallback, "")
But, I get the following error
# Error: TypeError: in method 'MTimerMessage_setSleepCallback',
argument 1 of type 'MTimerMessage::sleepCallbackPtr' #
This is a problem as I do not see sleepCallbackPtr available in
MTimerMessage.
dir(OpenMaya.MTimerMessage)
# Result: #
This is a none issue with the new MTimerMessage::addTimerCallback()
modification in 2011:
MTimerMessage::addTimerCallback() has been modified such that it no longer requires that Maya's idle queue run continuously. As such, the sleepCallback() and setSleepCallback() methods are no longer needed.
But, I need it to run in both 2010 and 2011. What am I not getting
here?
Thanks,
Ryan