예제 #1
0
 async def _prepare_actor(self, aref: ActorRefT,
                          beacon: NodeT) -> ActorRefT:
     coro: Any
     if isinstance(aref, Awaitable):
         # agent does not yield
         coro = aref
         if self._sinks:
             raise ImproperlyConfigured("Agent must yield to use sinks")
     else:
         # agent yields and is an AsyncIterator so we have to consume it.
         coro = self._slurp(aref, aiter(aref))
     req_version = (3, 8)
     cur_version = sys.version_info
     if cur_version >= req_version:
         if isinstance(self.channel, TopicT):
             name = self.channel.get_topic_name()
         else:
             name = "channel"
         task = asyncio.Task(
             self._execute_actor(coro, aref),
             loop=self.loop,
             name=f"{str(aref)}-{name}",
         )
     else:
         task = asyncio.Task(
             self._execute_actor(coro, aref),
             loop=self.loop,
         )
     task._beacon = beacon  # type: ignore
     aref.actor_task = task
     self._actors.add(aref)
     return aref
예제 #2
0
 async def _prepare_actor(self, aref: ActorRefT, beacon: NodeT) -> ActorRefT:
     coro: Any
     if isinstance(aref, Awaitable):
         # agent does not yield
         coro = aref
         if self._sinks:
             raise ImproperlyConfigured("Agent must yield to use sinks")
     else:
         # agent yields and is an AsyncIterator so we have to consume it.
         coro = self._slurp(aref, aiter(aref))
     task = asyncio.Task(self._execute_actor(coro, aref), loop=self.loop)
     task._beacon = beacon  # type: ignore
     aref.actor_task = task
     self._actors.add(aref)
     return aref