Documentation about greenlets with djhuey
See original GitHub issueIssue Description
Hi,
When trying to make use of greenlets workers, the consumer task just doesn’t work. I tried to monkey patch using gevent, but it seems the worker thread is not able to connect to DB.
Settings
HUEY = {
'connection': {'host': self.HUEY_HOST, 'port': self.HUEY_PORT},
}
Additional run_huey_greenlet
management command :
from huey.contrib.djhuey.management.commands.run_huey import Command as RunHueyCommand
from django.conf import settings
class Command(RunHueyCommand):
def __init__(self, *args, **kwargs):
if settings.HUEY.get('consumer', {}).get('worker_type') == 'greenlet':
from gevent import monkey
monkey.patch_all()
super(Command, self).__init__(*args, **kwargs)
CLI
./manage.py run_huey_greenlet
DatabaseError: DatabaseWrapper objects created in a thread can only be used in that same thread. The object with alias 'default' was created in thread id 139937579968256 and this is thread id 139937120251248.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Huey Extensions — huey 2.4.4 documentation - Read the Docs
The MiniHuey consumer runs inside a greenlet in your main application process. ... 'huey.contrib.djhuey', # Add this to the list. # ... )....
Read more >Low-level utilities — gevent 22.10.3.dev0 documentation
Represents a tree of greenlets. In gevent, the parent of a greenlet is usually the hub, so this tree is primarily arganized along...
Read more >[Django] #33092: PyMemcacheCache backend fails when ...
suggested in the Django documentation at: ... in gunicorn with the gevent worker class. ... by another greenlet: <bound method Waiter.switch of <gevent....
Read more >python 任务队列huey_huey:小型多线程任务队列 - CSDN Blog
multi-process, multi-thread or greenlet task execution models. schedule tasks to execute at a given time, or after a given delay.
Read more >Python 2.4.3 Multi Threading Change Number Of Concurrency ...
This package is an extension of huey contrib djhuey package that allows users ... read the documentation.huey supports: multiprocess multithread or greenlet ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It worked when patching the
manage.py
bootstrap script, as this is where the internal DB connection is made. Patching the actual command file doesn’t work as it’s too late.I think it’s worth mentioning that in the doc + troubleshooting, because :
Added docs: http://huey.readthedocs.io/en/latest/contrib.html#using-gevent