Ejemplo n.º 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);
}
Ejemplo n.º 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 );
    }
}
Ejemplo n.º 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);
	}
}
Ejemplo n.º 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);
	}
}
Ejemplo n.º 6
0
Archivo: core.c Proyecto: 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;
}
Ejemplo n.º 7
0
/*
 * 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();
}
Ejemplo n.º 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;
}
Ejemplo n.º 9
0
void PythonEngine::abortScript()
{
    Py_AddPendingCall(&scriptQuit, NULL);
}