New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot make weakref to gevent.queue.Queue object #1217

Closed
githrdw opened this Issue May 19, 2018 · 6 comments

Comments

Projects
None yet
4 participants
@githrdw

githrdw commented May 19, 2018

  • gevent version: 1.3
  • Python version: "Python 2.7.12"
  • Operating System: "Linux Ubuntu"

Description:

I was trying to get Ajenti running, which uses "gevent", but I ran into the following error:
TypeError: cannot create weak reference to 'gevent._queue.Queue' object

A week before it worked, with version v1.2.2 installed.

What I've run:

Ajenti tried to run the following code (in /usr/local/lib/python2.7/dist-packages/aj/util/broadcast_queue.py):

import weakref
from gevent.queue import Queue
class BroadcastQueue(object):
    def __init__(self):
        self._queues = []
    def register(self):
        q = Queue()
        self._queues.append(weakref.ref(q))
        return q
    def broadcast(self, val):
        for q in list(self._queues):
            if q():
                q().put(val)
            else:
                self._queues.remove(q)

@jamadden jamadden added the bug label May 19, 2018

@jamadden jamadden closed this in c08b9ed May 19, 2018

jamadden added a commit that referenced this issue May 19, 2018

Merge pull request #1218 from gevent/issue1217
Allow weakreferences to Queue objects. Fixes #1217.
@Zimeon-

This comment has been minimized.

Zimeon- commented May 27, 2018

Tried to apply this fix but didn't get it to work, still get the same error. Made the modifications (#1218) to _queue.pxd and queue.py, after that i compiled a new queue.pyc.

Did I miss something?

@jamadden

This comment has been minimized.

Member

jamadden commented May 27, 2018

@Zimeon- If you're talking about the changes in commit 7f403c3, those affect the Cython-compiled modules. You'd need to recompile with Cython plus the C compiler.

The workaround in #1211 about using a trivial Python subclass is simpler.

@Zimeon-

This comment has been minimized.

Zimeon- commented May 27, 2018

Yea, that was what I did, had the wront link copied :) thank you for the reply, I'll check that one out.

@alexsv

This comment has been minimized.

alexsv commented May 30, 2018

I'm getting "ValueError: gevent._queue.Queue has the wrong size, try recompiling. Expected 80, got 72" - is it something related to this change?
it happens during the mysql.connector.pooling.MySQLConnectionPool constructor call

@jamadden

This comment has been minimized.

Member

jamadden commented May 30, 2018

@alexsv There was a brief period of time when broken manylinux1 wheels were on PyPI. If you installed one of those, you need to reinstall gevent, which should get the source and compile it. You may need to clear pip caches, I'm not sure. See #1219

@alexsv

This comment has been minimized.

alexsv commented May 30, 2018

@jamadden thanks! that helped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment