当前位置: 首页>>代码示例>>C++>>正文


C++ PyErr_CheckSignals函数代码示例

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


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

示例1: CYCLE

PyObject *v3_write(PyObject *_, PyObject *args)
{
  Vj1b* dut = ((v3*)_)->dut;
  const char *s;
  Py_ssize_t n;
  if (!PyArg_ParseTuple(args, "s#", &s, &n))
    return NULL;

  for (Py_ssize_t i = 0; i < n; i++) {
    dut->uart0_data = s[i];
    dut->uart0_valid = 1;
    do {
      if (PyErr_CheckSignals())
        return NULL;
      CYCLE();
    } while (dut->uart0_rd == 0);
    do {
      if (PyErr_CheckSignals())
        return NULL;
      CYCLE();
    } while (dut->uart0_rd == 1);
  }

  dut->uart0_valid = 0;
  Py_RETURN_NONE;
}
开发者ID:wzab,项目名称:AFCK_J1B_FORTH,代码行数:26,代码来源:vsim.cpp

示例2: pyg_signal_watch_check

static gboolean
pyg_signal_watch_check(GSource *source)
{
    PyGILState_STATE state;
    GMainLoop *main_loop;

#ifdef HAVE_PYSIGNAL_SETWAKEUPFD
    PySignalWatchSource *real_source = (PySignalWatchSource *)source;
    GPollFD *poll_fd = &real_source->fd;
    unsigned char dummy;
    if (poll_fd->revents & G_IO_IN)
	read(poll_fd->fd, &dummy, 1);
#endif

    state = pyglib_gil_state_ensure();

    main_loop = pyg_get_current_main_loop();

    if (PyErr_CheckSignals() == -1 && main_loop != NULL) {
	PyErr_SetNone(PyExc_KeyboardInterrupt);
	g_main_loop_quit(main_loop);
    }

    pyglib_gil_state_release(state);

    return FALSE;
}
开发者ID:tizenorg,项目名称:platform.upstream.pygobject2,代码行数:27,代码来源:pygmainloop.c

示例3: riscos_sleep

int riscos_sleep(double delay)
{
	os_t starttime, endtime, time; /* monotonic times (centiseconds) */
	int *pollword, ret;
	osbool claimed;

        /* calculate end time */
	starttime = os_read_monotonic_time();
	if (starttime + 100.0*delay >INT_MAX)
		endtime = INT_MAX;
	else
		endtime = (os_t)(starttime + 100.0*delay);

	/* allocate (in RMA) and set pollword for xupcall_sleep */
	pollword = osmodule_alloc(4);
	*pollword = 1;

	time = starttime;
	ret = 0;
	while ( time<endtime && time>=starttime ) {
		xupcall_sleep (pollword, &claimed);
		if (PyErr_CheckSignals()) {
			ret = 1;
			break;
		}
		time = os_read_monotonic_time();
	}

	/* deallocate pollword */
	osmodule_free(pollword);
	return ret;
}
开发者ID:Oize,项目名称:pspstacklesspython,代码行数:32,代码来源:sleep.c

示例4: return

static PyObject *p_sendfd(PyObject *self, PyObject *args)
{
    int sock, fd, ret;
    PyObject *data;
    
    if(!PyArg_ParseTuple(args, "iiO", &sock, &fd, &data))
	return(NULL);
    if(!PyString_Check(data)) {
	PyErr_SetString(PyExc_TypeError, "datagram must be a string");
	return(NULL);
    }
    while(1) {
	Py_BEGIN_ALLOW_THREADS;
	ret = sendfd(sock, fd, PyString_AsString(data), PyString_Size(data));
	Py_END_ALLOW_THREADS;
	if(ret < 0) {
	    if(errno == EINTR) {
		if(PyErr_CheckSignals())
		    return(NULL);
		continue;
	    }
	    PyErr_SetFromErrno(PyExc_OSError);
	    return(NULL);
	}
	Py_RETURN_NONE;
    }
}
开发者ID:dolda2000,项目名称:ashd,代码行数:27,代码来源:htp.c

示例5: Simulator_run

static PyObject *
Simulator_run(Simulator *self, PyObject *args)
{
    PyObject *ret = NULL;
    int status, not_done;
    uint64_t chunk = 8192; 
    double max_time = DBL_MAX;
    if (Simulator_check_sim(self) != 0) {
        goto out;
    }
    if (!PyArg_ParseTuple(args, "|d", &max_time)) {
        goto out;
    }
    not_done = 1; 
    self->sim->max_time = max_time;
    while (not_done) {
        status = sim_simulate(self->sim, chunk);
        if (status < 0) {
            handle_library_error(status);
            goto out;
        }
        not_done = status != 0; 
        if (PyErr_CheckSignals() < 0) {
            goto out;
        }
    }
    /* return True if complete coalescence has occured */
    ret = self->sim->time < max_time ? Py_True : Py_False;
    Py_INCREF(ret);
out:
    return ret;
}
开发者ID:JereKoskela,项目名称:discsim,代码行数:32,代码来源:_discsimmodule.c

示例6: _posixshmem_shm_open_impl

static int
_posixshmem_shm_open_impl(PyObject *module, PyObject *path, int flags,
                          int mode)
/*[clinic end generated code: output=8d110171a4fa20df input=e83b58fa802fac25]*/
{
    int fd;
    int async_err = 0;
    const char *name = PyUnicode_AsUTF8(path);
    if (name == NULL) {
        return -1;
    }
    do {
        Py_BEGIN_ALLOW_THREADS
        fd = shm_open(name, flags, mode);
        Py_END_ALLOW_THREADS
    } while (fd < 0 && errno == EINTR && !(async_err = PyErr_CheckSignals()));

    if (fd < 0) {
        if (!async_err)
            PyErr_SetFromErrnoWithFilenameObject(PyExc_OSError, path);
        return -1;
    }

    return fd;
}
开发者ID:Eyepea,项目名称:cpython,代码行数:25,代码来源:posixshmem.c

示例7: color_setr

static int color_setr(PyColor *self, PyObject *value, void *closure)
{
    int v;

    if (PyErr_CheckSignals())
       return -1;

    if (!value)
    {
       PyErr_SetString(PyExc_TypeError, "Cannot delete red component");
       return -1;
    }

    if (!PyInt_Check(value))
    {
       PyErr_SetString(PyExc_TypeError, "Red component must be an integer.");
       return -1;
    }

    v = PyInt_AsLong(value);

    if ((v < 0) || (v > 255))
    {
       PyErr_SetString(PyExc_ValueError, "Red component must be between 0 and 255");
       return -1;
    }

    self->color = (self->color & 0xFFFFFF00U) | (u32)v;

    return 0;
}
开发者ID:Oize,项目名称:pspstacklesspython,代码行数:31,代码来源:color.cpp

示例8: _Py_open_impl

static int
_Py_open_impl(const char *pathname, int flags, int gil_held)
{
    int fd;
    int async_err = 0;
#ifndef MS_WINDOWS
    int *atomic_flag_works;
#endif

#ifdef MS_WINDOWS
    flags |= O_NOINHERIT;
#elif defined(O_CLOEXEC)
    atomic_flag_works = &_Py_open_cloexec_works;
    flags |= O_CLOEXEC;
#else
    atomic_flag_works = NULL;
#endif

    if (gil_held) {
        do {
            Py_BEGIN_ALLOW_THREADS
            fd = open(pathname, flags);
            Py_END_ALLOW_THREADS
        } while (fd < 0
                 && errno == EINTR && !(async_err = PyErr_CheckSignals()));
        if (async_err)
            return -1;
        if (fd < 0) {
            PyErr_SetFromErrnoWithFilename(PyExc_OSError, pathname);
            return -1;
        }
    }
    else {
开发者ID:asvetlov,项目名称:cpython,代码行数:33,代码来源:fileutils.c

示例9: image_getsizeY

static PyObject* image_getsizeY(PyImage *self, void *closure)
{
    if (PyErr_CheckSignals())
       return NULL;

    return Py_BuildValue("i", self->pImg->sizeY);
}
开发者ID:Oize,项目名称:pspstacklesspython,代码行数:7,代码来源:image.c

示例10: tb_printinternal

static int
tb_printinternal(tracebackobject *tb, PyObject *f, int limit)
{
	int err = 0;
	int depth = 0;
	tracebackobject *tb1 = tb;
	while (tb1 != NULL) {
		depth++;
		tb1 = tb1->tb_next;
	}
	while (tb != NULL && err == 0) {
		if (depth <= limit) {
			err = tb_displayline(f,
			    PyString_AsString(
				    tb->tb_frame->f_code->co_filename),
			    tb->tb_lineno,
			    PyString_AsString(tb->tb_frame->f_code->co_name));
		}
		depth--;
		tb = tb->tb_next;
		if (err == 0)
			err = PyErr_CheckSignals();
	}
	return err;
}
开发者ID:Belxjander,项目名称:Kirito,代码行数:25,代码来源:traceback.c

示例11: pspsnd_setSndFxVolume

static PyObject* pspsnd_setSndFxVolume(PyObject *self,
                                       PyObject *args,
                                       PyObject *kwargs)
{
    int volume;

    if (!PyArg_ParseTuple(args, "i:setSndFxVolume", &volume))
       return NULL;

    if (PyErr_CheckSignals())
       return NULL;

#ifdef CHECKTYPE
    if ((volume < 0) || (volume > 255))
    {
       PyErr_SetString(PyExc_ValueError, "Bad volume value");
       return NULL;
    }
#endif

    PSPSND::Sound::setVolume((unsigned char)volume);

    Py_INCREF(Py_None);
    return Py_None;
}
开发者ID:joshdekock,项目名称:jim-psp,代码行数:25,代码来源:pspsnd.cpp

示例12: image_getangle

static PyObject* image_getangle(PyImage *self, void *closure)
{
    if (PyErr_CheckSignals())
       return NULL;

    return Py_BuildValue("f", self->pImg->angle);
}
开发者ID:Oize,项目名称:pspstacklesspython,代码行数:7,代码来源:image.c

示例13: pyuv__check_signals

static void
pyuv__check_signals(uv_poll_t *handle, int status, int events)
{
    PyGILState_STATE gstate = PyGILState_Ensure();
    SignalChecker *self;

    ASSERT(handle);

    self = PYUV_CONTAINER_OF(handle, SignalChecker, poll_h);

    if (status == 0) {
        ASSERT(events == UV_READABLE);
    }

    /* Drain the fd */
    if (pyuv__drain_poll_fd(self->fd) != 0) {
        uv_poll_stop(handle);
    }

    /* Check for signals */
    PyErr_CheckSignals();
    if (PyErr_Occurred()) {
        handle_uncaught_exception(HANDLE(self)->loop);
    }

    Py_DECREF(self);

    PyGILState_Release(gstate);
}
开发者ID:Sevenops,项目名称:pyuv,代码行数:29,代码来源:util.c

示例14: color_getg

static PyObject* color_getg(PyColor *self, void *closure)
{
    if (PyErr_CheckSignals())
       return NULL;

    return Py_BuildValue("i", (self->color >> 8) & 0xFF);
}
开发者ID:Oize,项目名称:pspstacklesspython,代码行数:7,代码来源:color.cpp

示例15: readline_until_enter_or_signal

static char *
readline_until_enter_or_signal(const char *prompt, int *signal)
{
    char * not_done_reading = "";
    fd_set selectset;

    *signal = 0;
#ifdef HAVE_RL_CATCH_SIGNAL
    rl_catch_signals = 0;
#endif

    rl_callback_handler_install (prompt, rlhandler);
    FD_ZERO(&selectset);

    completed_input_string = not_done_reading;

    while (completed_input_string == not_done_reading) {
        int has_input = 0, err = 0;

        while (!has_input)
        {               struct timeval timeout = {0, 100000}; /* 0.1 seconds */

            /* [Bug #1552726] Only limit the pause if an input hook has been
               defined.  */
            struct timeval *timeoutp = NULL;
            if (PyOS_InputHook)
                timeoutp = &timeout;
            FD_SET(fileno(rl_instream), &selectset);
            /* select resets selectset if no input was available */
            has_input = select(fileno(rl_instream) + 1, &selectset,
                               NULL, NULL, timeoutp);
            err = errno;
            if(PyOS_InputHook) PyOS_InputHook();
        }

        if (has_input > 0) {
            rl_callback_read_char();
        }
        else if (err == EINTR) {
            int s;
#ifdef WITH_THREAD
            PyEval_RestoreThread(_PyOS_ReadlineTState);
#endif
            s = PyErr_CheckSignals();
#ifdef WITH_THREAD
            PyEval_SaveThread();
#endif
            if (s < 0) {
                rl_free_line_state();
                rl_cleanup_after_signal();
                rl_callback_handler_remove();
                *signal = 1;
                completed_input_string = NULL;
            }
        }
    }

    return completed_input_string;
}
开发者ID:1564143452,项目名称:kbengine,代码行数:59,代码来源:readline.c


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