Skip to content

Commit 2c8398d

Browse files
committed
fix iterator implementation
not every `__aiter__` returns self
1 parent 3bc37c4 commit 2c8398d

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

trio_asyncio/adapter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ def __aexit__(self, *tb):
9090
return self.loop.run_aio_coroutine(f)
9191

9292
def __aiter__(self):
93-
proc_iter = getattr(self.proc, "__anext__", None)
93+
proc_iter = getattr(self.proc, "__aiter__", None)
9494
if proc_iter is None or self.args:
9595
raise RuntimeError(
9696
"Call 'aio_as_trio(gen(*args))', not 'aio_as_trio(gen, *args)'"
9797
)
98-
return run_aio_generator(self.loop, self.proc)
98+
return run_aio_generator(self.loop, proc_iter())
9999

100100

101101
def aio_as_trio(proc, loop=None):
@@ -150,12 +150,12 @@ def __aexit__(self, *tb):
150150
return self.loop.trio_as_future(f, *tb)
151151

152152
def __aiter__(self):
153-
proc_iter = getattr(self.proc, "__anext__", None)
153+
proc_iter = getattr(self.proc, "__aiter__", None)
154154
if proc_iter is None or self.args:
155155
raise RuntimeError(
156156
"Call 'aio_as_trio(gen(*args))', not 'aio_as_trio(gen, *args)'"
157157
)
158-
return run_trio_generator(self.loop, self.proc)
158+
return run_trio_generator(self.loop, proc_iter())
159159

160160

161161
def trio_as_aio(proc, loop=None):

0 commit comments

Comments
 (0)