static PyObject * _channel_send_sequence(PyChannelObject *self, PyObject *v) { PyObject *it; int i; PyObject *ret; it = PyObject_GetIter(v); if (it == NULL) return NULL; /* Run iterator to exhaustion. */ for (i = 0; ; i++) { PyObject *item = PyIter_Next(it); if (item == NULL) { if (PyErr_Occurred()) goto error; break; } ret = impl_channel_send(self, item); Py_DECREF(item); if (ret == NULL) goto error; Py_DECREF(ret); } Py_DECREF(it); return PyInt_FromLong(i); error: Py_DECREF(it); return NULL; }
static PyObject * channel_send(PyObject *myself, PyObject *arg) { return impl_channel_send((PyChannelObject*)myself, arg); }
PyObject * channel_seq_callback(PyFrameObject *_f, int exc, PyObject *retval) { PyThreadState *ts; PyCFrameObject *f = (PyCFrameObject *) _f; PyChannelObject *ch; PyObject *item; int stage = f->n; /* prolog to re-enter the loop */ if (stage == 1) { item = retval; goto back_with_data; } if (retval == NULL) goto exit_frame; Py_DECREF(retval); retval = NULL; if (stage == 2) { goto back_from_send; } /* Run iterator to exhaustion. */ for (; ; f->i++) { /* get the data */ STACKLESS_PROPOSE_ALL(); item = PyIter_Next(f->ob1); if (STACKLESS_UNWINDING(item)) { stage = f->n = 1; return item; } back_with_data: if (item == NULL) { if (PyErr_Occurred()) { if (PyErr_ExceptionMatches( PyExc_StopIteration)) PyErr_Clear(); else goto exit_frame; } break; } /* send the data */ ch = (PyChannelObject *) f->ob2; STACKLESS_PROPOSE_ALL(); retval = impl_channel_send(ch, item); Py_DECREF(item); if (retval == NULL) goto exit_frame; if (STACKLESS_UNWINDING(retval)) { stage = f->n = 2; return retval; } Py_DECREF(retval); back_from_send: ; } retval = PyInt_FromLong(f->i); exit_frame: /* epilog to return from the frame */ ts = PyThreadState_GET(); ts->frame = f->f_back; Py_DECREF(f); return retval; }
int PyChannel_Send(PyChannelObject *self, PyObject *arg) { return slp_return_wrapper_hard(impl_channel_send(self, arg)); }
int PyChannel_Send_nr(PyChannelObject *self, PyObject *arg) { STACKLESS_PROPOSE_ALL(); return slp_return_wrapper(impl_channel_send(self, arg)); }