'Django Celery django.db.utils.OperationalError
Hi I'm having a really strange problem with celery. I have a model like this
class MyUser(models.model):
email = models.CharField(max_length=255, unique=True, blank=False, null=False)
.....
user_code = models.PositiveIntegerField(default=get_user_code, unique=True, blank=False, null=False)
def get_random_num():
return random.randint(10000, 999999)
def get_user_code():
# Check if some user with this code already exists
code = get_random_num()
while MyUser.objects.filter(user_code=code).exists():
code = get_random_num()
return code
So django is not complaining on this, but for some reason when I start celery I have errors like this:
django.db.utils.OperationalError: could not receive data from server: Bad file descriptor
Django schedule tasks will not run, other celery tasks run just fine (example: sending emails).
So django is not complaining on this but Celery does.
If I just remove this lines of code, celery is not showing any errors.
while MyUser.objects.filter(user_code=code).exists():
code = get_random_num()
Why is Celery complaining on this? Did someone already faced this issue? Is there some clean way to avoid this?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
