You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I am using janus, very happily, to mix async and threaded code, and it works great.
I have just a little suggestion about the API: I think you should provide a head() or peek() method, that allows to get the first element in the queue without removing it. Although this is not really necessary (also, you provide a PriorityQueue), I think it's a great addition which could make user code easier.
The current get() method could be implemented using head() + removal, so code should stay reasonably similar to the current.
This would allow to take decisions earlier, without messing with queue order.
The text was updated successfully, but these errors were encountered:
It's not very helpful because of concurrent nature: a value returned by peek() could be different from the value from subsequent get() call if the queue has multiple consumers.
Standard queue.Queue and asyncio.Queue have no peek() methods exactly for the same reason.
You're right! But it's helpful when there is a single consumer :) In my use case, I have multiple producing threads and a single (async) consumer. But I get your point, I'm still happy with janus even if you won't include it.
Hello,
I am using janus, very happily, to mix async and threaded code, and it works great.
I have just a little suggestion about the API: I think you should provide a
head()
orpeek()
method, that allows to get the first element in the queue without removing it. Although this is not really necessary (also, you provide aPriorityQueue
), I think it's a great addition which could make user code easier.The current
get()
method could be implemented usinghead()
+ removal, so code should stay reasonably similar to the current.This would allow to take decisions earlier, without messing with queue order.
The text was updated successfully, but these errors were encountered: