-
Notifications
You must be signed in to change notification settings - Fork 452
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
fix django.db.backends import in patch_thread_ident #476
Conversation
I am somewhat worried about this fix, since the original fix from Have you actually reproduced the error and then seen it fixed after this PR? As a side-note, I fail to understand what this monkey-patching actually does. It seems to replace |
yes, actually reproduced, and it works for me. see the issue #402 |
return | ||
|
||
if 'validate_thread_sharing' in BaseDatabaseWrapper.__dict__: | ||
try: | ||
import thread |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import doesn't work on Python 3. You should also try to import _thread
for this patch to work on py3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed. thanks.
I've had the same issue with djcelery in Django 1.9.x and manually applying these changes locally has fixed it for me. As for gunicorn, benoitc/gunicorn#927 looks related (still open as of right now). |
Really strange. This works fine on Windows, but as soon as I deploy it to Linux (Heroku), the original exception is back. |
So the problem still occurs with this patch with the pool class |
@hheimbuerger, can you check if the problem persists when running without django-celery? If so, I would suggest filing a bug with Celery. |
@vytisb I cannot really check, unfortunately, as my project heavily depends on django-celery. Or do you mean just without the Django ORM queue? |
@mx14 @vytisb Can one of you add some more detail to what's going on here? I've been trying to understand what this code does and what causes the problems with Django 1.9, but I couldn't really find any statement of intent besides this cryptic note:
What are 'real threads'? Which 'unreal threads' is Django using when it isn't patched? It seems to want to overwrite the For mysterious reasons, it also seems to overwrite the method I've also done some debugging, and in my case (prefork), The reason is that the patch is applied as part of the |
@hheimbuerger, I've looked into this patch and I believe I can explain it. First, Now, Therefore, I think that this PR should not be merged and instead All that said, this should have no effect when not using
Are you using |
@vytisb Thanks a lot for your detailled explanation! So basically, you're saying this problem shouldn't even occur when using the prefork model? When I was debugging, I thought I had seen the I'm using a Is there any documentation or other reading material to better understand all of these fixups: what they do and why, and how they are initialized in the different cases and the various versions of Django they support? |
No,
There isn't any documentation, AFAIK. I found out about
With that, I think, the discussion should move to celery/celery#3520 since the problem should be outside django-celery. |
@vytisb You're right, thanks so much for your responses! I've since identified another library as the culprit (which ran even more gevent patching in my non-gevent environment), so my apologies for bringing confusing details to this unrelated PR. I'll go into more detail on celery/celery#3520. |
BaseDatabaseWrapper and DatabaseError were moved to django.db.backends.base.base package since django 1.8.
django/django@2830807#diff-53fcf3ac0535307033e0cfabb85c5301