Commit 7f403c3e authored by Jason Madden's avatar Jason Madden Committed by GitHub

Merge pull request #1218 from gevent/issue1217

Allow weakreferences to Queue objects. Fixes #1217.
parents 6728bd08 c08b9edf
...@@ -7,13 +7,14 @@ ...@@ -7,13 +7,14 @@
1.3.2 (unreleased) 1.3.2 (unreleased)
================== ==================
- Nothing changed yet. - Allow weak refeneces to :class:`gevent.queue.Queue`. Reported in
:issue:`1217` by githrdw.
1.3.1 (2018-05-18) 1.3.1 (2018-05-18)
================== ==================
- Fix weak references to :class:`gevent.event.Event`. Reported in - Allow weak references to :class:`gevent.event.Event`. Reported in
:issue:`1211` by Matias Guijarro. :issue:`1211` by Matias Guijarro.
- Fix embedded uses of :func:`gevent.Greenlet.spawn`, especially under - Fix embedded uses of :func:`gevent.Greenlet.spawn`, especially under
......
...@@ -16,14 +16,15 @@ cdef class ItemWaiter(Waiter): ...@@ -16,14 +16,15 @@ cdef class ItemWaiter(Waiter):
cdef readonly queue cdef readonly queue
cdef class Queue: cdef class Queue:
cdef __weakref__
cdef readonly hub cdef readonly hub
cdef readonly queue cdef readonly queue
cdef Py_ssize_t _maxsize
cdef getters cdef getters
cdef putters cdef putters
cdef _event_unlock cdef _event_unlock
cdef Py_ssize_t _maxsize
cpdef _get(self) cpdef _get(self)
cpdef _put(self, item) cpdef _put(self, item)
...@@ -61,6 +62,7 @@ cdef class JoinableQueue(Queue): ...@@ -61,6 +62,7 @@ cdef class JoinableQueue(Queue):
cdef class Channel: cdef class Channel:
cdef __weakref__
cdef readonly getters cdef readonly getters
cdef readonly putters cdef readonly putters
cdef readonly hub cdef readonly hub
......
...@@ -113,6 +113,7 @@ class Queue(object): ...@@ -113,6 +113,7 @@ class Queue(object):
'hub', 'hub',
'_event_unlock', '_event_unlock',
'queue', 'queue',
'__weakref__',
) )
def __init__(self, maxsize=None, items=(), _warn_depth=2): def __init__(self, maxsize=None, items=(), _warn_depth=2):
...@@ -558,6 +559,7 @@ class Channel(object): ...@@ -558,6 +559,7 @@ class Channel(object):
'putters', 'putters',
'hub', 'hub',
'_event_unlock', '_event_unlock',
'__weakref__',
) )
def __init__(self, maxsize=1): def __init__(self, maxsize=1):
......
...@@ -377,8 +377,16 @@ class TestJoinEmpty(TestCase): ...@@ -377,8 +377,16 @@ class TestJoinEmpty(TestCase):
q = queue.JoinableQueue() q = queue.JoinableQueue()
q.join() q.join()
class AbstractTestWeakRefMixin(object):
class TestGetInterrupt(AbstractGenericGetTestCase): def test_weak_reference(self):
import weakref
one = self._makeOne()
ref = weakref.ref(one)
self.assertIs(one, ref())
class TestGetInterrupt(AbstractTestWeakRefMixin, AbstractGenericGetTestCase):
Timeout = Empty Timeout = Empty
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment