async def send(self, item): """Handles the transmission of a single item from the pipeline. Each send operation is run as a task, so that in case of multiple consumers, a stuck consumer won't block the entire send loop. :param item: The item to send. :type item: Any """ for _ in range(self.retrys + 1): with trio.move_on_after(self.timeout): try: await self.send_channel.send(item) except trio.BrokenResourceError: self.closed = True return await trio.sleep(0) raise trio.BusyResourceError('Unable to send item.')
def __enter__(self): if self._held: raise trio.BusyResourceError(self._msg) else: self._held = True