Skip to content
This repository has been archived by the owner on Jul 20, 2020. It is now read-only.

Queue or LifoQueue #32

Closed
ArthurJ opened this issue Aug 27, 2017 · 4 comments
Closed

Queue or LifoQueue #32

ArthurJ opened this issue Aug 27, 2017 · 4 comments

Comments

@ArthurJ
Copy link

ArthurJ commented Aug 27, 2017

It would be nice to have a LifoQueue ticker to get always the most recent information.

@alexeykarnachev
Copy link
Contributor

alexeykarnachev commented Aug 28, 2017

Such approach would cause the memory error because you need to do something with the rest part of messages in queue (not only with the last one)
In other words, you need to consume all messages from subscribed channel.
I think, LIFO could help if only the fixed size of queues will be implemented. Before it's done, you can just do the while loop through all messages in queue and get only the last one

@ArthurJ
Copy link
Author

ArthurJ commented Aug 28, 2017

Yeah, that's what I did. The loop is not a problem.
[ticker_q.get() for _ in range(ticker_q.qsize())][-N:]

The fixed size is necessary indeed, this implementation seems to be useful to client programmers that need the N most recent tickers.

@deepbrook
Copy link
Collaborator

I have thought about a LIFO queue as well, however, at this point the library is intentionally rather bare bones. It would technically be no problem to implement this yourself - simply call get() on the Queue and fill it into a deque which then allows you to keep a history of the past X ticks of ticker data.

@deepbrook
Copy link
Collaborator

With the introduction of zmq in the next release and the deprecation of the current client interface, this issue is no longer relevant.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants