Closed agronholm closed 4 years ago
Thank you for your contribution, unfortunately I worked on similar fixes last week, after my tests I released cysystemd==1.4.0
and it's conflicts with this changeset.
No problem, so long as the bugs get fixed. I should take a look at your new code and see if it checks out.
@agronholm actually you third case not fixed yet. I'm trying to fix it without removing AsyncReaderIterator
right now.
You can use the same approach there. I can make a PR if you like.
@agronholm I fixed it here I will happy if you could test it on your cases
Why did you add a .pyi
file? Why not just add the type annotations to the code itself? It's not like Python < 3.5 can parse the code anyway with all those async def
s and await
statements there.
Tell me what you think of my alternative fix. I'm going to bed now.
The simplest way to iterate it would be this:
# ... in the AsyncJournalReader class
def __aiter__(self):
return self
async def __anext__(self):
try:
return await self._loop.run_in_executor(self._executor, self.__reader.next)
except StopIteration:
raise StopAsyncIteration
Do you really intend to do something about multiple concurrent iterators? Or raise an error when that is being tried?
Waiting on a synchronous lock is admittedly not very good, but I also think that there is no need for a separate iterator class.
Hmm – am I understanding this correctly? If I do for entry in reader:
it will read entries in a non-blocking fashion until there are no entries anymore, and then we need to wait on the reader to get more entries?
Oh... sorry I merged the wrong PR. Master has been force updated, if you still want to fix it please create a new one against master.
Fixes #28.