I've already reported this error on the closed issue of another project - Flask-SocketIO.
https://github.com/miguelgrinberg/Flask-SocketIO/issues/112
An exception occurs with the modules below.
``` requirements.txt
Flask==0.10.1
gevent==1.0.2
greenlet==0.4.7
gunicorn==19.3.0 # worker_class = 'gevent'
supervisor==3.1.3
In a few minutes after the error occurred, my web application didn't answer anymore, so I had to terminate processes manually. It's because the processes couldn't be stopped even if using supervisorctl command.
``` python
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/eventlet/hubs/poll.py", line 115, in wait
listener.cb(fileno)
File "/usr/local/lib/python2.7/site-packages/gevent/greenlet.py", line 331, in run
self._report_result(result)
File "/usr/local/lib/python2.7/site-packages/gevent/greenlet.py", line 306, in _report_result
self._notifier = self.parent.loop.run_callback(self._notify_links)
AttributeError: 'greenlet.greenlet' object has no attribute 'loop'
Removing descriptor: 18
Interesting. Can you provide a minimal reproducible example?
I'm concerned about the appearance of eventlet in the traceback. Do you know what's pulling that in? The gunicorn/gevent/flask stack does not appear to pull eventlet in, and I'm surprised to see it. I'm wondering if that's the source of the trouble (I have no idea how eventlet and gevent would interact).
$ mkvirtualenv flask-gevent
$ pip install flask gevent greenlet gunicorn supervisor
$ pip freeze
Flask==0.10.1
gevent==1.0.2
greenlet==0.4.7
gunicorn==19.3.0
itsdangerous==0.24
Jinja2==2.7.3
MarkupSafe==0.23
meld3==1.0.2
supervisor==3.1.3
Werkzeug==0.10.4
Sorry for the late reply.
You are right. eventlet had been installed in my environment as well.
I'm sure that I've installed it manually before to evaluate both softwares.
$ pip install eventlet==0.17.4
You may reproduce the same issue by installing both gevent and eventlet and running gunicorn with gevent worker class.
Closing during triage for 1.1 and because the issue was environmental (having eventlet and gevent both installed and fighting over the event loop).
I wanted to know if there is any other way to solve this issue without removing eventlet
I am building a web app using python-socketio, gevent and Flask along with uWSGi as a hosting server. I am having problems while monkey patching, and it is giving me the above mentioned error.
Can you direct me to a proper way to monkey patch and use SocketIO?
Any form of help will be appreciated!
I'm having this issue with the error:
task.start()
File "src/gevent/greenlet.py", line 524, in gevent._greenlet.Greenlet.start
AttributeError: 'greenlet.greenlet' object has no attribute 'loop'
I don't have eventlet installed and I'm using macOS
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.14.6
BuildVersion: 18G103
The versions I'm using are:
$ pip list | grep ^g.*
gensim 3.7.1
gevent 1.4.0
greenlet 0.4.15
The above exception is happening on this situation:
````python
task = Task(...)
config = task.get_config()
logger.info("[run] Starting task: %s, config: %r", args.task, config)
task.start()
gevent.joinall([task])
```
Task is a class that inherit from gevent.Greenlet.
Would be possible to get any pointer / help?
@andrix That means that the parent attribute of your Task object is not gevent's hub, it's probably the default "main" greenlet that's automatically established for each thread. Greenlet objects must have the hub as their parent.
Normally, Greenlet.__init__ sets its parent to the hub. Make sure you're calling Greenlet.__init__ if your Task subclass overrides __init__. Otherwise, if you're manually setting task.parent = something_else...don't :)
@jamadden Thank you very much! I have identified the issue about 1 hour ago, and I was about to update it here.
The issue was with the Greenlet initialization, as there was a inheritance chain of tasks, and one of those was missing the super(WorkerTask).__init__(..) (note the missing self there).
It would be super useful to have a cleaner message when this happens, that if it's failing in loop because there is no parent, it's because a failed initialization of the Greenlet.
Most helpful comment
Closing during triage for 1.1 and because the issue was environmental (having eventlet and gevent both installed and fighting over the event loop).