예제 #1
0
static void
signal_handler(int sig_num)
{
#ifdef WITH_THREAD
#ifdef WITH_PTH
	if (PyThread_get_thread_ident() != main_thread) {
		pth_raise(*(pth_t *) main_thread, sig_num);
		return;
	}
#endif
	/* See NOTES section above */
	if (getpid() == main_pid) {
#endif
		is_tripped++;
		Handlers[sig_num].tripped = 1;
		Py_AddPendingCall(checksignals_witharg, NULL);
#ifdef WITH_THREAD
	}
#endif
#ifdef SIGCHLD
	if (sig_num == SIGCHLD) {
		/* To avoid infinite recursion, this signal remains
		   reset until explicit re-instated.
		   Don't clear the 'func' field as it is our pointer
		   to the Python handler... */
		return;
	}
#endif
#ifdef HAVE_SIGINTERRUPT
	siginterrupt(sig_num, 1);
#endif
	PyOS_setsig(sig_num, signal_handler);
}
예제 #2
0
/* Replacements for intrcheck.c functionality
 * Declared in pyerrors.h
 */
void
PyErr_SetInterrupt(void)
{
	is_tripped++;
	Handlers[SIGINT].tripped = 1;
	Py_AddPendingCall((int (*)(void *))PyErr_CheckSignals, NULL);
}
//--------------------------------------------------------------------------------
//
//    Python Watch Dog
//
//--------------------------------------------------------------------------------
static DWORD WINAPI python_watch_dog_starter( LPVOID )
{
    for(;;)
    {
        WaitForSingleObject( h_watch_dog_queued_event, INFINITE );
        Sleep( 50 );

        Py_AddPendingCall( python_watch_dog, NULL );
    }
}
예제 #4
0
/* Routine passed to NewSndChannel -- schedule a call to SndCh_CallCallBack */
static pascal void
SndCh_UserRoutine(SndChannelPtr chan, SndCommand *cmd)
{
	SndChannelObject *p = (SndChannelObject *)(chan->userInfo);
	if (p->ob_callback != NULL) {
		long A5 = SetA5(p->ob_A5);
		p->ob_cmd = *cmd;
		Py_AddPendingCall(SndCh_CallCallBack, (void *)p);
		SetA5(A5);
	}
}
예제 #5
0
static pascal void
SPB_completion(SPBPtr my_spb)
{
	SPBObject *p = (SPBObject *)(my_spb->userLong);
	
	if (p && p->ob_completion) {
		long A5 = SetA5(p->ob_A5);
		p->ob_thiscallback = p->ob_completion;	/* Hope we cannot get two at the same time */
		Py_AddPendingCall(SPB_CallCallBack, (void *)p);
		SetA5(A5);
	}
}
예제 #6
0
파일: core.c 프로젝트: fried/pyaio
static void aio_completion_handler(sigval_t sigval)
{
    Pyaio_cb *aio;
    aio = (Pyaio_cb*) sigval.sival_ptr;

    /* Hybrid Approach if Pending fails grab GIL do it directly */
    if(Py_AddPendingCall(&_async_callback, aio) < 0) {
        PyGILState_STATE state = PyGILState_Ensure();
        _async_callback(aio);
        PyGILState_Release(state);
    }

    return;
}
예제 #7
0
파일: plpy_main.c 프로젝트: magi345/gpdb
/*
 * For GPDB Use: Hook function, called when current query is being cancelled
 * (on e.g. SIGINT or SIGTERM)
 *
 * NB: This is called from a signal handler!
 */
void
PLy_handle_cancel_interrupt(void)
{
	/*
	 * We can't do much in a signal handler, so just tell the Python
	 * interpreter to call us back when possible.
	 *
	 * We don't bother to check the return value, as there's nothing we could
	 * do if it fails for some reason.
	 */
	if (PLy_enter_python_intepreter)
		(void) Py_AddPendingCall(PLy_python_cancel_handler, NULL);

	if (prev_cancel_pending_hook)
		prev_cancel_pending_hook();
}
예제 #8
0
static PyObject* MMSV2GUI_invokeLater(PyObject *self, PyObject *args)
{
  PyObject* pObject = NULL;

  if (!PyArg_ParseTuple(args, "O", &pObject))
   return NULL;

  if(Action_Check(pObject))
  {
    PyMMSAction* pAction = new PyMMSAction;

    Py_INCREF(pObject);
    pAction->pCallback = pObject;

    Py_AddPendingCall(Py_MMS_InvokeLater, pAction);
    Py_PulseActionEvent();
  }

  Py_INCREF(Py_None);
  return Py_None;
}
예제 #9
0
void PythonEngine::abortScript()
{
    Py_AddPendingCall(&scriptQuit, NULL);
}