• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PyEval_InitThreads函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中PyEval_InitThreads函数的典型用法代码示例。如果您正苦于以下问题:C++ PyEval_InitThreads函数的具体用法?C++ PyEval_InitThreads怎么用?C++ PyEval_InitThreads使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了PyEval_InitThreads函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char *argv[])
{
    int err;

#ifdef __WIN32__
    //Let's make sure we're in the directory where the executable
    //is since this is required for Makehuman to function on Windows
    //Makehuman will fail to start if you're not in the same directory
    //as the executable
    TCHAR exepath[MAX_PATH];
    if (0 == GetModuleFileName(0, exepath, MAX_PATH)) {
	fprintf(stderr, "coulnd't get executable path\n");
    }
    else {
	PathRemoveFileSpec(exepath);
	SetCurrentDirectory(exepath);
    }
#endif

    Py_SetProgramName(argv[0]);
#if 0
    Py_SetPythonHome(".");
#endif
    Py_Initialize();

    if (!Py_IsInitialized())
    {
        fprintf(stderr, "Could not initialize Python\n");
        exit(EXIT_FAILURE);
    }

    PySys_SetArgv(argc, argv);

    PyEval_InitThreads();

    err = PyRun_SimpleString("execfile('makehuman.py')");

    if (err != 0)
    {
        fprintf(stderr, "Could not run main Python script\n");
        getchar();
        exit(EXIT_FAILURE);
    }

    Py_Finalize();

    return 0;
}
开发者ID:RuliLG,项目名称:makehuman,代码行数:48,代码来源:main.c


示例2: embed_init_python

void embed_init_python(void)
{
    FENTER;

#ifndef PYTHON_SO_LIB
#error "Python version needs passing in with -DPYTHON_SO_VERSION=libpython<ver>.so"
#else
#define PY_SO_LIB xstr(PYTHON_SO_LIB)
#endif

    // Don't initialise python if already running
    if (gtstate)
        return;

    void * ret = utils_dyn_open(PY_SO_LIB);
    if (!ret) {
        fprintf(stderr, "Failed to find python lib\n");
    }

    Py_SetProgramName(progname);
    Py_Initialize();                    /* Initialize the interpreter */
    PySys_SetArgvEx(1, argv, 0);
    PyEval_InitThreads();               /* Create (and acquire) the interpreter lock */

    /* Swap out and return current thread state and release the GIL */
    gtstate = PyEval_SaveThread();

    /* Before returning we check if the user wants pause the simulator thread
       such that they can attach */
    const char *pause = getenv("COCOTB_ATTACH");
    if (pause) {
        long sleep_time = strtol(pause, NULL, 10);
        if (errno == ERANGE && (sleep_time == LONG_MAX || sleep_time == LONG_MIN)) {
            fprintf(stderr, "COCOTB_ATTACH only needs to be set to ~30 seconds");
            goto out;
        }
        if ((errno != 0 && sleep_time == 0) ||
            (sleep_time <= 0)) {
            fprintf(stderr, "COCOTB_ATTACH must be set to an integer base 10 or omitted");
            goto out;
        }

        fprintf(stderr, "Waiting for %lu seconds - Attach to %d\n", sleep_time, getpid());
        sleep(sleep_time);
    }
out:
    FEXIT;
}
开发者ID:ambikeshwar1991,项目名称:cocotb,代码行数:48,代码来源:gpi_embed.c


示例3: mraa_init

mraa_init()
{
    /** Once more board definitions have been added,
     *  A method for detecting them will need to be devised.
     */
    if (plat != NULL) {
        return MRAA_ERROR_PLATFORM_ALREADY_INITIALISED;
    }
#ifdef SWIGPYTHON
    // Initialise python threads, this allows use to grab the GIL when we are
    // required to do so
    Py_InitializeEx(0);
    PyEval_InitThreads();
#endif
    // detect a galileo gen2 board
    char *line = NULL;
    // let getline allocate memory for *line
    size_t len = 0;
    FILE *fh = fopen("/sys/devices/virtual/dmi/id/board_name", "r");
    if (fh != NULL) {
        if (getline(&line, &len, fh) != -1) {
            if (strncmp(line, "GalileoGen2", 10) == 0) {
                platform_type = MRAA_INTEL_GALILEO_GEN2;
            } else {
                platform_type = MRAA_INTEL_GALILEO_GEN1;
            }
            free(line);
        }
        fclose(fh);
    }

    advance_func = (mraa_adv_func_t*) malloc(sizeof(mraa_adv_func_t));
    memset(advance_func, 0, sizeof(mraa_adv_func_t));

    switch(platform_type) {
        case MRAA_INTEL_GALILEO_GEN2:
            plat = mraa_intel_galileo_gen2();
            break;
        case MRAA_INTEL_GALILEO_GEN1:
            plat = mraa_intel_galileo_rev_d();
            break;
        default:
            plat = mraa_intel_galileo_rev_d();
            fprintf(stderr, "Platform not found, initialising MRAA_INTEL_GALILEO_GEN1\n");
    }

    return MRAA_SUCCESS;
}
开发者ID:alexandruradovici,项目名称:mraa,代码行数:48,代码来源:mraa.c


示例4: _py_init_interpreter

static void
_py_init_interpreter(void)
{
  if (!interpreter_initialized)
    {
      python_debugger_append_inittab();

      Py_Initialize();

      PyEval_InitThreads();
      python_log_message_init();
      PyEval_SaveThread();

      interpreter_initialized = TRUE;
    }
}
开发者ID:Achint08,项目名称:syslog-ng,代码行数:16,代码来源:python-plugin.c


示例5: thread_PyThread_start_new_thread

static PyObject *
thread_PyThread_start_new_thread(PyObject *self, PyObject *fargs)
{
	PyObject *func, *args, *keyw = NULL;
	struct bootstate *boot;
	long ident;

	if (!PyArg_UnpackTuple(fargs, "start_new_thread", 2, 3,
		               &func, &args, &keyw))
		return NULL;
	if (!PyCallable_Check(func)) {
		PyErr_SetString(PyExc_TypeError,
				"first arg must be callable");
		return NULL;
	}
	if (!PyTuple_Check(args)) {
		PyErr_SetString(PyExc_TypeError,
				"2nd arg must be a tuple");
		return NULL;
	}
	if (keyw != NULL && !PyDict_Check(keyw)) {
		PyErr_SetString(PyExc_TypeError,
				"optional 3rd arg must be a dictionary");
		return NULL;
	}
	boot = PyMem_NEW(struct bootstate, 1);
	if (boot == NULL)
		return PyErr_NoMemory();
	boot->interp = PyThreadState_GET()->interp;
	boot->func = func;
	boot->args = args;
	boot->keyw = keyw;
	Py_INCREF(func);
	Py_INCREF(args);
	Py_XINCREF(keyw);
	PyEval_InitThreads(); /* Start the interpreter's thread-awareness */
	ident = PyThread_start_new_thread(t_bootstrap, (void*) boot);
	if (ident == -1) {
		PyErr_SetString(ThreadError, "can't start new thread");
		Py_DECREF(func);
		Py_DECREF(args);
		Py_XDECREF(keyw);
		PyMem_DEL(boot);
		return NULL;
	}
	return PyInt_FromLong(ident);
}
开发者ID:1310701102,项目名称:sl4a,代码行数:47,代码来源:threadmodule.c


示例6: annoy

void annoy(int count)
{
    count = std::max(count, 0);

    if (!PyEval_ThreadsInitialized())
    {
        PyEval_InitThreads();
    }

#ifdef PRINT_DEBUG_MESSAGES
    std::cout << "checking thread pool for removal" << std::endl;
#endif
    while(count < threads.size())
    {
#ifdef PRINT_DEBUG_MESSAGES
        std::cout << "stopping thread" << std::endl;
#endif
        auto& back = threads.back();
        back.second->quit = true;
        back.first.join();
#ifdef PRINT_DEBUG_MESSAGES
        std::cout << "removing thread" << std::endl;
#endif
        threads.pop_back();
    }

#ifdef PRINT_DEBUG_MESSAGES
    std::cout << "checking thread pool for additions" << std::endl;
#endif
    while(count > threads.size())
    {
#ifdef PRINT_DEBUG_MESSAGES
        std::cout << "creating thread" << std::endl;
#endif
        threads.push_back(thread_data{});
#ifdef PRINT_DEBUG_MESSAGES
        std::cout << "setting thread" << std::endl;
#endif
        auto& back = threads.back();
        back.second = std::make_shared<thread_parms>();
        back.second->quit = false;
#ifdef PRINT_DEBUG_MESSAGES
        std::cout << "launching thread" << std::endl;
#endif
        back.first = std::thread(worker, back.second);
    }
}
开发者ID:after5cst,项目名称:python-extend-with-threads,代码行数:47,代码来源:annoymodule.cpp


示例7: main

int main(int argc, char* argv[])
{
    PyEval_InitThreads();
    Py_Initialize();
    PyObject* sysPath = PySys_GetObject((char*) "path");
    PyList_Append(sysPath, PyString_FromString("."));

    PyObject *pModule = NULL, *pClass = NULL, *pInst = NULL;
    do
    {
        PyGILState_STATE state = PyGILState_Ensure();
        {
            pModule = PyImport_ImportModule("worker");
            if (pModule == NULL) break;

            pClass = PyObject_GetAttrString(pModule, "ThreadManager");
            if (pClass == NULL) break;

            pInst = PyObject_CallObject(pClass, NULL);
            if (pInst == NULL) break;

            PyObject_CallMethod(pInst, "start_thread", NULL);
        }
        PyGILState_Release(state);

        for (int i = 0; i < 5; i++)
        {
            printf("main thread is running\n");
            sleep(1);
        }

        state = PyGILState_Ensure();
        {
            PyObject_CallMethod(pInst, "stop_thread", NULL);
        }
        PyGILState_Release(state);

        printf("finish\n");
    } while (0);

    Py_XDECREF(pInst);
    Py_XDECREF(pClass);
    Py_XDECREF(pModule);

    Py_Finalize();
    return 0;
}
开发者ID:wagamama,项目名称:embedding_python,代码行数:47,代码来源:tutorial-3NG.c


示例8: initaudiodev

PyMODINIT_FUNC
initaudiodev(void)
{
    PyObject *m;
    
    PyEval_InitThreads();

    m = Py_InitModule3("audiodev", Module_methods, "portable audio device module based on the RtAudio project");
    if (m == NULL)
        return;

    _rtaudio = new RtAudio();
    
    ModuleError = PyErr_NewException("audiodev.error", NULL, NULL);
    Py_INCREF(ModuleError);
    PyModule_AddObject(m, "error", ModuleError);
}
开发者ID:theintencity,项目名称:py-audio,代码行数:17,代码来源:audiodev.cpp


示例9: initrtaudio

PyMODINIT_FUNC
initrtaudio(void) 
{
  PyEval_InitThreads();
  import_libnumarray();
  import_libnumeric();

  PyObject* module;
  
  if (PyType_Ready(&RtAudio_type) < 0)
    return;
  
  module = Py_InitModule3("rtaudio", rtaudio_methods,
			  "RtAudio wrapper.");

  PyRTAUDIO_SINT8 = PyLong_FromUnsignedLong(RTAUDIO_SINT8);
  PyModule_AddObject(module, "RTAUDIO_SINT8", PyRTAUDIO_SINT8);
  Py_INCREF(PyRTAUDIO_SINT8);

  PyRTAUDIO_SINT16 = PyLong_FromUnsignedLong(RTAUDIO_SINT16);
  PyModule_AddObject(module, "RTAUDIO_SINT16", PyRTAUDIO_SINT16);
  Py_INCREF(PyRTAUDIO_SINT16);

  PyRTAUDIO_SINT24 = PyLong_FromUnsignedLong(RTAUDIO_SINT24);
  PyModule_AddObject(module, "RTAUDIO_SINT24", PyRTAUDIO_SINT24);
  Py_INCREF(PyRTAUDIO_SINT24);

  PyRTAUDIO_SINT32 = PyLong_FromUnsignedLong(RTAUDIO_SINT32);
  PyModule_AddObject(module, "RTAUDIO_SINT32", PyRTAUDIO_SINT32);
  Py_INCREF(PyRTAUDIO_SINT32);

  PyRTAUDIO_FLOAT32 = PyLong_FromUnsignedLong(RTAUDIO_FLOAT32);
  PyModule_AddObject(module, "RTAUDIO_FLOAT32", PyRTAUDIO_FLOAT32);
  Py_INCREF(PyRTAUDIO_FLOAT32);

  PyRTAUDIO_FLOAT64 = PyLong_FromUnsignedLong(RTAUDIO_FLOAT64);
  PyModule_AddObject(module, "RTAUDIO_FLOAT64", PyRTAUDIO_FLOAT64);
  Py_INCREF(PyRTAUDIO_FLOAT64);
  
  Py_INCREF(&RtAudio_type);
  PyModule_AddObject(module, "RtAudio", (PyObject *)&RtAudio_type);
  
  RtAudioError = PyErr_NewException("rtaudio.RtError", NULL, NULL);
  PyModule_AddObject(module, "RtError", RtAudioError);
  Py_INCREF(RtAudioError);
}
开发者ID:RikVerschueren,项目名称:AccordionMega,代码行数:46,代码来源:rtaudiomodule.cpp


示例10: init_jpype

PyMODINIT_FUNC init_jpype()
{
	Py_Initialize();
	PyEval_InitThreads();
	  
	PyObject* module = Py_InitModule("_jpype", jpype_methods);  
	Py_INCREF(module);
	hostEnv = new PythonHostEnvironment();
	  
	JPEnv::init(hostEnv);

	PyJPMonitor::initType(module);	
	PyJPMethod::initType(module);	
	PyJPBoundMethod::initType(module);	
	PyJPClass::initType(module);	
	PyJPField::initType(module);	
}
开发者ID:Koblaid,项目名称:jpype,代码行数:17,代码来源:jpype_python.cpp


示例11: MPyEmbed_Init

void MPyEmbed_Init(void) {
	if (!PythonAvailable) {
		PythonAvailable = initlinkage();
	}
	if (!PythonAvailable) {
		return;
	}
	PyEval_InitThreads();
	Py_Initialize();

	initpydega();

	PySys_SetArgv(argc, argv);
	mainstate = PyEval_SaveThread();
	memset(threaddata, 0, sizeof(threaddata));
	threaddatalock = PyThread_allocate_lock();
}
开发者ID:Plombo,项目名称:dega,代码行数:17,代码来源:embed.c


示例12: ui_thread_create_thread

// @pymethod |PyCWinThread|CreateThread|Creates the actual thread behind the thread object.
static PyObject *
ui_thread_create_thread(PyObject *self, PyObject *args)
{
	DWORD createFlags = 0;
	UINT stackSize = 0;
	if (!PyArg_ParseTuple(args, "|li:CreateThread", &createFlags, &stackSize))
		return NULL;
	CWinThread *pThread = GetCWinThreadPtr(self);
	if (!pThread) return NULL;
	PyEval_InitThreads();
	GUI_BGN_SAVE;
	BOOL ok = pThread->CreateThread(createFlags, stackSize);
	GUI_END_SAVE;
	if (!ok)
		RETURN_ERR("CreateThread failed");
	RETURN_NONE;
}
开发者ID:malrsrch,项目名称:pywin32,代码行数:18,代码来源:win32thread.cpp


示例13: mraa_init

mraa_init()
{
    if (plat != NULL) {
        return MRAA_ERROR_PLATFORM_ALREADY_INITIALISED;
    }

    uid_t proc_euid = geteuid();
    struct passwd* proc_user = getpwuid(proc_euid);

#ifdef DEBUG
    setlogmask(LOG_UPTO(LOG_DEBUG));
#else
    setlogmask(LOG_UPTO(LOG_NOTICE));
#endif

    openlog("libmraa", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
    syslog(LOG_NOTICE, "libmraa version %s initialised by user '%s' with EUID %d",
           mraa_get_version(), (proc_user != NULL) ? proc_user->pw_name : "<unknown>", proc_euid);

#ifdef SWIGPYTHON
    // Initialise python threads, this allows use to grab the GIL when we are
    // required to do so
    Py_InitializeEx(0);
    PyEval_InitThreads();
#endif
    advance_func = (mraa_adv_func_t*) malloc(sizeof(mraa_adv_func_t));
    memset(advance_func, 0, sizeof(mraa_adv_func_t));

#if defined(X86PLAT)
    // Use runtime x86 platform detection
    platform_type = mraa_x86_platform();
#elif defined(ARMPLAT)
    // Use runtime ARM platform detection
    platform_type = mraa_arm_platform();
#else
#error mraa_ARCH NOTHING
#endif

    if (plat == NULL) {
        printf("mraa: FATAL error, failed to initialise platform\n");
        return MRAA_ERROR_PLATFORM_NOT_INITIALISED;
    }

    syslog(LOG_INFO, "libmraa initialised for platform '%s' of type %d", mraa_get_platform_name(), platform_type);
    return MRAA_SUCCESS;
}
开发者ID:zBMNForks,项目名称:mraa,代码行数:46,代码来源:mraa.c


示例14: initvisit

initvisit(void)
{
    if(moduleState == NULL)
    {
        moduleState = (VisItModuleState*)malloc(sizeof(VisItModuleState));
        memset(moduleState, 0, sizeof(VisItModuleState));
    }

    /* Make sure that threads are init'd */
    PyEval_InitThreads();

    /* Add the VisIt module to Python. Note that we're passing just a
     * couple of methods and then the interface that we load will
     * get the rest of the functions.
     */
    Py_InitModule("visit", visit_methods);
}
开发者ID:ahota,项目名称:visit_intel,代码行数:17,代码来源:visitfrontend.c


示例15: on_startup

static int on_startup() {
  struct stat fi;
  if (!project_app || !*project_app) {
    nxweb_log_error("python wsgi app not specified; skipping python initialization");
    return 0;
  }
  static const char* prog_name="python/nxwebpy.py";
  if (stat(prog_name, &fi)==-1) {

#ifdef NXWEB_LIBDIR
    prog_name=NXWEB_LIBDIR "/nxwebpy.py";
    if (stat(prog_name, &fi)==-1) {
#endif

      nxweb_log_error("%s is missing; skipping python initialization", prog_name);
      return 0;

#ifdef NXWEB_LIBDIR
    }
#endif

  }

  Py_SetProgramName((char*)prog_name);
  // initialize thread support
  PyEval_InitThreads();
  Py_Initialize();
  char *a[]={(char*)prog_name, (char*)project_root, (char*)project_app, (char*)virtualenv_path};
  PySys_SetArgv(4, a);
  PyObject* py_module_name=PyString_FromString(MODULE_NAME);
  assert(py_module_name);
  // save a pointer to the main PyThreadState object
  py_main_thread_state=PyThreadState_Get();
  py_module=PyImport_Import(py_module_name);
  if (!py_module || !PyModule_Check(py_module)) {
    fprintf(stderr, "can't load python module %s; check parse errors:\n", MODULE_NAME);
    PyErr_Print();
    exit(0);
  }
  Py_DECREF(py_module_name);
  py_nxweb_on_request_func=PyObject_GetAttrString(py_module, FUNC_NAME);
  assert(py_nxweb_on_request_func && PyCallable_Check(py_nxweb_on_request_func));
  // release the lock
  PyEval_ReleaseLock();
  return 0;
}
开发者ID:liexusong,项目名称:NXWEB,代码行数:46,代码来源:python.c


示例16: QQmlExtensionPlugin

// Construct the C++ plugin.
PyQt5QmlPlugin::PyQt5QmlPlugin(QObject *parent) : QQmlExtensionPlugin(parent),
        py_plugin_obj(0), sip(0)
{
    // Make sure the interpreter is initialised.
    if (!Py_IsInitialized())
    {
        Py_Initialize();

        getSipAPI();

#ifdef WITH_THREAD
        // Make sure we don't have the GIL.
        PyEval_InitThreads();
        PyEval_SaveThread();
#endif
    }
}
开发者ID:HunterChen,项目名称:pyqt5,代码行数:18,代码来源:pluginloader.cpp


示例17: __pyx_f_7withgil_f

/* Implementation of withgil */

static void __pyx_f_7withgil_f(void) {
  PyObject *__pyx_v_x;
  PyObject *__pyx_1 = 0;
  PyGILState_STATE _save = PyGILState_Ensure();
  __pyx_v_x = Py_None; Py_INCREF(Py_None);
  __pyx_1 = PyInt_FromLong(42); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}
  Py_DECREF(__pyx_v_x);
  __pyx_v_x = __pyx_1;
  __pyx_1 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_WriteUnraisable("withgil.f");
  __pyx_L0:;
  Py_DECREF(__pyx_v_x);
  PyGILState_Release(_save);
}

static PyObject *__pyx_f_7withgil_g(PyObject *__pyx_v_x) {
  PyObject *__pyx_r;
  PyGILState_STATE _save = PyGILState_Ensure();
  Py_INCREF(__pyx_v_x);

  __pyx_r = Py_None; Py_INCREF(Py_None);
  Py_DECREF(__pyx_v_x);
  PyGILState_Release(_save);
  return __pyx_r;
}

static struct PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

static void __pyx_init_filenames(void); /*proto*/

PyMODINIT_FUNC initwithgil(void); /*proto*/
PyMODINIT_FUNC initwithgil(void) {
  #if PY_VERSION_HEX < 0x02040000 && defined(WITH_THREAD)
    PyEval_InitThreads();
  #endif
  __pyx_init_filenames();
  __pyx_m = Py_InitModule4("withgil", __pyx_methods, 0, 0, PYTHON_API_VERSION);
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  Py_INCREF(__pyx_m);
  __pyx_b = PyImport_AddModule("__builtin__");
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};

  /* "/Local/Projects/D/Pyrex/Source/Tests/9/withgil.pyx":4 */
  return;
  __pyx_L1:;
  __Pyx_AddTraceback("withgil");
}
开发者ID:jwilk,项目名称:Pyrex,代码行数:57,代码来源:withgil.c


示例18: ODBG2_Pluginquery

/*
    This routine is required by the OllyDBG plugin engine! 
*/
extc int __cdecl ODBG2_Pluginquery(int ollydbgversion, ulong *features, wchar_t pluginname[SHORTNAME], wchar_t pluginversion[SHORTNAME])
{
    // Yeah, the plugin interface in the v1/v2 are different
    if(ollydbgversion < 201)
        return 0;

    // Set plugin name and version
    wcscpy_s(pluginname, SHORTNAME, L"python-loader");
    wcscpy_s(pluginversion, SHORTNAME, L"v0.1");

    // Initialize the python environment, prepare the hooks
    Py_Initialize();
    PyEval_InitThreads();

    Addtolist(0x31337, RED, NAME_PLUGIN L" Plugin fully initialized.");

    return PLUGIN_VERSION;
}
开发者ID:0vercl0k,项目名称:ollydbg2-python,代码行数:21,代码来源:main.cpp


示例19: initgtask

initgtask (void)
{
	PyObject *m, *d;

	PyEval_InitThreads ();
	init_pygobject ();

	m = Py_InitModule ("gtask", pygtask_functions);
	d = PyModule_GetDict (m);

	pygtask_register_classes (d);
	pygtask_add_constants (m, "G_");

	if (PyErr_Occurred ())
		Py_FatalError ("Error initializing module GTask");

	pyg_enable_threads ();
}
开发者ID:chergert,项目名称:gtask,代码行数:18,代码来源:gtaskmodule.c


示例20: initxormasker

// Python 2.7
PyMODINIT_FUNC initxormasker(void)
{
#ifdef WITH_THREAD /* Python build with threading support? */
    PyEval_InitThreads();
#endif

    /* Create the module */
    PyObject *module = Py_InitModule3("xormasker", utf8validator_methods, "xormasker module");

    if (!module)
    {
        // TODO: Add some error message
        return;
    }

    /* Register the Exception used in the module */
    XorMaskerException = PyErr_NewException("autobahn.xormasker.XorMaskerException", NULL, NULL);

    /* Fill in missing slots in type XorMaskerNullType */
    XorMaskerNullType.tp_new = PyType_GenericNew;

    if (PyType_Ready(&XorMaskerNullType) < 0)
    {
        // TODO: Add some error message
        return;
    }

    /* Add the type XorMaskerNullType to the module */
    Py_INCREF(&XorMaskerNullType);
    PyModule_AddObject(module, "XorMaskerNull", (PyObject*) &XorMaskerNullType);

    /* Fill in missing slots in type XorMaskerSimpleType */
    XorMaskerSimpleType.tp_new = PyType_GenericNew;

    if (PyType_Ready(&XorMaskerSimpleType) < 0)
    {
        // TODO: Add some error message
        return;
    }

    /* Add the type XorMaskerSimpleType to the module */
    Py_INCREF(&XorMaskerSimpleType);
    PyModule_AddObject(module, "XorMaskerSimple", (PyObject*) &XorMaskerSimpleType);
}
开发者ID:Aerobota,项目名称:autobahn_rce,代码行数:45,代码来源:xormasker.c



注:本文中的PyEval_InitThreads函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PyEval_ReleaseLock函数代码示例发布时间:2022-05-30
下一篇:
C++ PyEval_CallObject函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap