MCPcopy Index your code
hub / github.com/python/cpython / SendChannel

Class SendChannel

Lib/test/support/channels.py:177–274  ·  view source on GitHub ↗

The sending end of a cross-interpreter channel.

Source from the content-addressed store, hash-verified

175
176
177class SendChannel(_ChannelEnd):
178 """The sending end of a cross-interpreter channel."""
179
180 _end = 'send'
181
182# def __new__(cls, cid, *, _unbound=None):
183# if _unbound is None:
184# try:
185# op = _channels.get_channel_defaults(cid)
186# _unbound = (op,)
187# except ChannelNotFoundError:
188# _unbound = _serialize_unbound(UNBOUND)
189# self = super().__new__(cls, cid)
190# self._unbound = _unbound
191# return self
192
193 def _set_unbound(self, op, items=None):
194 assert not hasattr(self, '_unbound')
195 if items is None:
196 items = _resolve_unbound(op)
197 unbound = (op, items)
198 self._unbound = unbound
199 return unbound
200
201 @property
202 def unbounditems(self):
203 try:
204 _, items = self._unbound
205 except AttributeError:
206 op, _ = _channels.get_queue_defaults(self._id)
207 _, items = self._set_unbound(op)
208 return items
209
210 @property
211 def is_closed(self):
212 info = self._info
213 return info.closed or info.closing
214
215 def send(self, obj, timeout=None, *,
216 unbounditems=None,
217 ):
218 """Send the object (i.e. its data) to the channel's receiving end.
219
220 This blocks until the object is received.
221 """
222 if unbounditems is None:
223 unboundop = -1
224 else:
225 unboundop, = _serialize_unbound(unbounditems)
226 _channels.send(self._id, obj, unboundop, timeout=timeout, blocking=True)
227
228 def send_nowait(self, obj, *,
229 unbounditems=None,
230 ):
231 """Send the object to the channel's receiving end.
232
233 If the object is immediately received then return True
234 (else False). Otherwise this is the same as send().

Callers 2

createFunction · 0.85
list_allFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…