Skip to content

Add tornado.queues.#1380

Merged
bdarnell merged 5 commits intotornadoweb:masterfrom
ajdavis:queues
Mar 16, 2015
Merged

Add tornado.queues.#1380
bdarnell merged 5 commits intotornadoweb:masterfrom
ajdavis:queues

Conversation

@ajdavis
Copy link
Contributor

@ajdavis ajdavis commented Mar 15, 2015

This is consistent with the latest API for asyncio. It raises special QueueFull and QueueEmpty errors instead of the standard Queue.Full and Queue.Empty, and there is no separate JoinableQueue, see Tulip issue 220.

LifoQueue and PriorityQueue will come next.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an unfortunate precedent: channels with a zero bound (so a put() can only proceed when there is a waiting get()) have proven surprisingly useful in Go. But given the precedent, we should keep 0 as unbounded and use a separate class or option for zero-bounded queues if we introduce them (and I'd need to think more about whether zero-bounded queues can make sense without the select statement).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds like very interesting future work. Incidentally, maxsize=0 once worked this way in Gevent, and they changed to match the standard Queue, introducing "Channel" instead:

http://www.gevent.org/whatsnew_1_0.html#api-changes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, a separate class probably makes the most sense. IIRC go has three different channel implementations and picks one based on the capacity (0, 1, or other)

@ajdavis
Copy link
Contributor Author

ajdavis commented Mar 15, 2015

New patch.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to cancel the timeout when the operation resolves; see the pattern used in gen.with_timeout. (also applies to get(), and we should double-check all the timeouts in locks.py).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Fixed in this PR for queues, will submit a separate PR for locks.

bdarnell added a commit that referenced this pull request Mar 16, 2015
@bdarnell bdarnell merged commit f5c0704 into tornadoweb:master Mar 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants