retry on maya failure

This commit is contained in:
David Rose
2009-04-22 00:35:18 +00:00
parent ea1e5d205e
commit 78cc74bdf1
3 changed files with 24 additions and 0 deletions
+10
View File
@@ -23,6 +23,16 @@ ConfigureFn(config_maya) {
init_libmaya();
}
ConfigVariableInt init_maya_repeat_count
("init-maya-repeat-count", 5,
PRC_DESC("The number of times to attempt to initialize Maya and acquire the "
"Maya license before giving up."));
ConfigVariableDouble init_maya_timeout
("init-maya-timeout", 5.0,
PRC_DESC("The number of seconds to wait between attempts to acquire the "
"Maya license."));
////////////////////////////////////////////////////////////////////
// Function: init_libmaya
// Description: Initializes the library. This must be called at
+5
View File
@@ -17,9 +17,14 @@
#include "pandatoolbase.h"
#include "notifyCategoryProxy.h"
#include "configVariableInt.h"
#include "configVariableDouble.h"
NotifyCategoryDeclNoExport(maya);
extern ConfigVariableInt init_maya_repeat_count;
extern ConfigVariableDouble init_maya_timeout;
extern void init_libmaya();
#endif
+9
View File
@@ -15,6 +15,7 @@
#include "mayaApi.h"
#include "config_maya.h"
#include "string_utils.h"
#include "thread.h"
#include "pre_maya_include.h"
#include <maya/MGlobal.h>
@@ -65,6 +66,14 @@ MayaApi(const string &program_name) {
// any Maya function! Egad!
_cwd = ExecutionEnvironment::get_cwd();
MStatus stat = MLibrary::initialize((char *)program_name.c_str());
int error_count = init_maya_repeat_count;
while (!stat && error_count > 1) {
stat.perror("MLibrary::initialize");
Thread::sleep(init_maya_timeout);
stat = MLibrary::initialize((char *)program_name.c_str());
--error_count;
}
// Restore the current directory.
string dirname = _cwd.to_os_specific();