Skip to content
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

UnicodeDecodeError on journalctl log #425

Open
chiara-paci opened this issue Jul 19, 2022 · 2 comments
Open

UnicodeDecodeError on journalctl log #425

chiara-paci opened this issue Jul 19, 2022 · 2 comments

Comments

@chiara-paci
Copy link

When django raise a 500 error (f.e. following a ValueError), instead of exception stacktrace on journalctl log there is an UnicodeDecodeError.

Environment: Debian 10.12, Python 3.7.3, Django 3.2.5, Daphne 3.0.2, Apache 2.4.38

Systemd Unit File:

[Unit]
Description=baskerville Daphne Service
Requires=srv.mount
After=network.target 
After=srv.mount
 
[Service]
Type=simple 
User=chiara
WorkingDirectory=/srv/projects/baskerville.mygor.xyz/baskervilleweb
ExecStart=daphne --access-log /var/log/daphne/daphne-baskerville.log -b 127.0.0.1 -p 9000 baskervilleweb.asgi:application  Environment=PYTHONUNBUFFERED=1
   
[Install]
WantedBy=multi-user.target

Sample output

In a queryset, I define an annotation with the same name as a field:

class FoodDiaryEntryManager(models.Manager):
    def get_queryset(self):
        qset=models.Manager.get_queryset(self)
        return qset.annotate(
            qta=models.F("quantity")*models.F("measure_unit__factor"),
            ratio=models.F("quantity")*models.F("measure_unit__factor")/100
        ).annotate(
             kcal=models.F("ratio")*models.F("product__kcal")
        )

class FoodDiaryEntry(models.Model):
    ...
    product = models.ForeignKey(Product,on_delete=models.PROTECT)
    measure_unit = models.ForeignKey(MeasureUnit,on_delete=models.PROTECT)
    quantity = models.FloatField(validators=[validators.MinValueValidator(0.0)])
    ...
    kcal          = models.FloatField(editable=False)
    ...
    objects = FoodDiaryEntryManager()

The expected behaviour on journalctl log is an exception stacktrace with something like (from django console):

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/lib/python3.7/dist-packages/django/db/models/query.py", line 1091, in annotate
    return self._annotate(args, kwargs, select=True)
  File "/usr/local/lib/python3.7/dist-packages/django/db/models/query.py", line 1126, in _annotate
    "the model." % alias)
ValueError: The annotation 'kcal' conflicts with a field on the model.

Instead I have:

# journalctl -f -u daphne-baskerville.service
...
Jul 19 10:47:24 parsifal daphne[26088]: --- Logging error ---
Jul 19 10:47:24 parsifal daphne[26088]: Traceback (most recent call last):
Jul 19 10:47:24 parsifal daphne[26088]:   File "/usr/lib/python3.7/logging/__init__.py", line 1034, in emit
Jul 19 10:47:24 parsifal daphne[26088]:     msg = self.format(record)
Jul 19 10:47:24 parsifal daphne[26088]:   File "/usr/lib/python3.7/logging/__init__.py", line 880, in format
Jul 19 10:47:24 parsifal daphne[26088]:     return fmt.format(record)
Jul 19 10:47:24 parsifal daphne[26088]:   File "/usr/lib/python3.7/logging/__init__.py", line 627, in format
Jul 19 10:47:24 parsifal daphne[26088]:     record.exc_text = self.formatException(record.exc_info)
Jul 19 10:47:24 parsifal daphne[26088]:   File "/usr/lib/python3.7/logging/__init__.py", line 577, in formatException
Jul 19 10:47:24 parsifal daphne[26088]:     traceback.print_exception(ei[0], ei[1], tb, None, sio)
Jul 19 10:47:24 parsifal daphne[26088]:   File "/usr/lib/python3.7/traceback.py", line 104, in print_exception
Jul 19 10:47:24 parsifal daphne[26088]:     type(value), value, tb, limit=limit).format(chain=chain):
Jul 19 10:47:24 parsifal daphne[26088]:   File "/usr/lib/python3.7/traceback.py", line 521, in __init__
Jul 19 10:47:24 parsifal daphne[26088]:     self._load_lines()
Jul 19 10:47:24 parsifal daphne[26088]:   File "/usr/lib/python3.7/traceback.py", line 533, in _load_lines
Jul 19 10:47:24 parsifal daphne[26088]:     self.__context__._load_lines()
Jul 19 10:47:24 parsifal daphne[26088]:   File "/usr/lib/python3.7/traceback.py", line 533, in _load_lines
Jul 19 10:47:24 parsifal daphne[26088]:     self.__context__._load_lines()
Jul 19 10:47:24 parsifal daphne[26088]:   File "/usr/lib/python3.7/traceback.py", line 533, in _load_lines
Jul 19 10:47:24 parsifal daphne[26088]:     self.__context__._load_lines()
Jul 19 10:47:24 parsifal daphne[26088]:   [Previous line repeated 5 more times]
Jul 19 10:47:24 parsifal daphne[26088]:   File "/usr/lib/python3.7/traceback.py", line 531, in _load_lines
Jul 19 10:47:24 parsifal daphne[26088]:     frame.line
Jul 19 10:47:24 parsifal daphne[26088]:   File "/usr/lib/python3.7/traceback.py", line 285, in line
Jul 19 10:47:24 parsifal daphne[26088]:     self._line = linecache.getline(self.filename, self.lineno).strip()
Jul 19 10:47:24 parsifal daphne[26088]:   File "/usr/lib/python3.7/linecache.py", line 16, in getline
Jul 19 10:47:24 parsifal daphne[26088]:     lines = getlines(filename, module_globals)
Jul 19 10:47:24 parsifal daphne[26088]:   File "/usr/lib/python3.7/linecache.py", line 47, in getlines
Jul 19 10:47:24 parsifal daphne[26088]:     return updatecache(filename, module_globals)
Jul 19 10:47:24 parsifal daphne[26088]:   File "/usr/lib/python3.7/linecache.py", line 137, in updatecache
Jul 19 10:47:24 parsifal daphne[26088]:     lines = fp.readlines()
Jul 19 10:47:24 parsifal daphne[26088]:   File "/usr/lib/python3.7/codecs.py", line 322, in decode
Jul 19 10:47:24 parsifal daphne[26088]:     (result, consumed) = self._buffer_decode(data, self.errors, final)
Jul 19 10:47:24 parsifal daphne[26088]: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd7 in position 4907: invalid continuation byte
Jul 19 10:47:24 parsifal daphne[26088]: Call stack:
Jul 19 10:47:24 parsifal daphne[26088]:   File "/usr/local/bin/daphne", line 8, in <module>
Jul 19 10:47:24 parsifal daphne[26088]:     sys.exit(CommandLineInterface.entrypoint())
Jul 19 10:47:24 parsifal daphne[26088]:   File "/usr/local/lib/python3.7/dist-packages/daphne/cli.py", line 170, in entrypoint
Jul 19 10:47:24 parsifal daphne[26088]:     cls().run(sys.argv[1:])
Jul 19 10:47:24 parsifal daphne[26088]:   File "/usr/local/lib/python3.7/dist-packages/daphne/cli.py", line 285, in run
Jul 19 10:47:24 parsifal daphne[26088]:     self.server.run()
Jul 19 10:47:24 parsifal daphne[26088]:   File "/usr/local/lib/python3.7/dist-packages/daphne/server.py", line 143, in run
Jul 19 10:47:24 parsifal daphne[26088]:     reactor.run(installSignalHandlers=self.signal_handlers)
Jul 19 10:47:24 parsifal daphne[26088]:   File "/usr/local/lib/python3.7/dist-packages/twisted/internet/asyncioreactor.py", line 255, in run
Jul 19 10:47:24 parsifal daphne[26088]:     self._asyncioEventloop.run_forever()
Jul 19 10:47:24 parsifal daphne[26088]:   File "/usr/lib/python3.7/asyncio/base_events.py", line 539, in run_forever
Jul 19 10:47:24 parsifal daphne[26088]:     self._run_once()
Jul 19 10:47:24 parsifal daphne[26088]:   File "/usr/lib/python3.7/asyncio/base_events.py", line 1775, in _run_once
Jul 19 10:47:24 parsifal daphne[26088]:     handle._run()
Jul 19 10:47:24 parsifal daphne[26088]:   File "/usr/lib/python3.7/asyncio/events.py", line 88, in _run
Jul 19 10:47:24 parsifal daphne[26088]:     self._context.run(self._callback, *self._args)
Jul 19 10:47:24 parsifal daphne[26088]:   File "/usr/local/lib/python3.7/dist-packages/twisted/internet/asyncioreactor.py", line 271, in _onTimer
Jul 19 10:47:24 parsifal daphne[26088]:     self.runUntilCurrent()
Jul 19 10:47:24 parsifal daphne[26088]:   File "/usr/local/lib/python3.7/dist-packages/twisted/internet/base.py", line 991, in runUntilCurrent
Jul 19 10:47:24 parsifal daphne[26088]:     call.func(*call.args, **call.kw)
Jul 19 10:47:24 parsifal daphne[26088]:   File "/usr/local/lib/python3.7/dist-packages/daphne/server.py", line 293, in application_checker
Jul 19 10:47:24 parsifal daphne[26088]:     exc_info=exception,
Jul 19 10:47:24 parsifal daphne[26088]: Message: 'Exception inside application: %s'
Jul 19 10:47:24 parsifal daphne[26088]: Arguments: (UnicodeDecodeError('utf-8', b'from django.db import models\nfrom django.core import validators\nfrom django.core.exceptions import ValidationError\nfrom django.utils import timezone\nfrom django.conf import settings\n\nimport datetime\n\nUser=settings.AUTH_USER_MODEL\n\n# Create your models here.\n\nclass AbstractName(models.Model):\n    name = models.CharField(max_length=1024)\n\n    def __str__(self): return str(self.name)\n\n    class Meta:\n        ordering = [ \'name\' ]\n        abstract = True\n\nclass Vendor(AbstractName): pass\nclass MicroNutrientClass(AbstractName): pass\n\nclass MicroNutrient(AbstractName):\n    nutrient_class = models.ForeignKey(MicroNutrientClass,on_delete=models.PROTECT)\n    rda = models.FloatField(validators=[validators.MinValueValidator(0.0)],\n                            verbose_name=\'rda (mg)\',default=0.0)\n    rda_max = models.FloatField(validators=[validators.MinValueValidator(0.0)],\n                                verbose_name=\'rda max (mg)\',default=0.0)\n\nclass ProductCategory(AbstractName): pass\n    \nclass Product(models.Model):\n    name = models.CharField(max_length=1024)\n    note = models.TextField(blank=True,null=True)\n    category = models.ForeignKey(ProductCategory,on_delete=models.PROTECT)\n    vendor = models.ForeignKey(Vendor,on_delete=models.PROTECT)\n    value_for = models.CharField(max_length=128,default=\'100 g\',\n                                 choices = ( ( "100 g", "100 g" ),\n                                             ( "100 ml", "100 ml" ) ))\n    high_processed = models.BooleanField(default=False)\n    kcal           = models.PositiveIntegerField()\n    fat            = models.FloatField(validators=[validators.MinValueValidator(0.0)])\n    saturated_fat  = models.FloatField(validators=[validators.MinValueValidator(0.0)],blank=True,default=0.0)\n    carbohydrate   = models.FloatField(validators=[validators.MinValueValidator(0.0)])\n    sugar          = models.FloatField(validators=[validators.MinValueValidator(0.0)],blank=True,default=0.0)\n    added_sugar    = models.FloatField(validators=[validators.MinValueValidator(0.0)],blank=True,default=0.0)\n    protein        = models.FloatField(validators=[validators.MinValueValidator(0.0)])\n    alcohol         = models.FloatField(validators=[validators.MinValueValidator(0.0)],blank=True,default=0.0)\n    alcohol_content = models.FloatField(validators=[validators.MinValueValidator(0.0),\n                                                    validators.MaxValueValidator(100.0)],\n                                        verbose_name="alcohol content (%)",\n                                        blank=True,default=0.0)\n    salt           = models.FloatField(validators=[validators.MinValueValidator(0.0)],\n                                       verbose_name="salt (g)",blank=True,default=0.0)\n    sodium         = models.FloatField(validators=[validators.MinValueValidator(0.0)],\n                                       verbose_name="sodium (g)",blank=True,default=0.0)\n    potassium      = models.FloatField(validators=[validators.MinValueValidator(0.0)],\n                                       verbose_name="potassium (g)",blank=True,default=0.0)\n    fiber          = models.FloatField(validators=[validators.MinValueValidator(0.0)],\n                                       verbose_name="fiber (g)",blank=True,default=0.0)\n    water          = models.FloatField(validators=[validators.MinValueValidator(0.0)],\n                                       verbose_name="water (ml)",blank=True,default=0.0)\n\n    micro_nutrients = models.ManyToManyField(MicroNutrient,through=\'ProductMicroNutrient\',blank=True)\n\n    class Meta:\n        ordering = [ \'name\',\'vendor\' ]\n\n    def save(self,*args,**kwargs):\n        if self.salt == 0 and self.sodium > 0:\n            self.salt=self.sodium/0.4\n        if self.sodium == 0 and self.salt > 0:\n            self.sodium=self.salt*0.4\n        if self.alcohol == 0 and self.alcohol_content > 0:\n            WATER_DENS=1\n            ALCOHOL_DENS=0.79\n            alcohol_factor=self.alcohol_content/100\n\n            if self.value_for == "100 ml":\n                tot_vol=100\n            else:\n                tot_dens=( (1-alcohol_factor)*WATER_DENS + alcohol_factor*ALCOHOL_DENS )\n                tot_vol=100/tot_dens\n            alcohol_vol=alcohol_factor*tot_vol\n            self.alcohol=ALCOHOL_DENS*alcohol_vol\n                \n        super(Product, self).save(*args,**kwargs)\n\n    def __str__(self): \n        return "%s (%s)" %(str(self.name),str(self.vendor))\n\nclass ProductMicroNutrient(models.Model):\n    product = models.ForeignKey(Product,on_delete=models.PROTECT)   \n    micro_nutrient = models.ForeignKey(MicroNutrient,on_delete=models.PROTECT)\n    quantity = models.FloatField(validators=[validators.MinValueValidator(0.0)],verbose_name=\'quantity (mg)\')\n\n    def __str__(self): return str(self.micro_nutrient)\n    \nclass MeasureUnit(AbstractName):\n    base = models.CharField(max_length=128,default=\'g\',choices = ( ( "g", "g" ),\n                                                                   ( "ml", "ml" ) ))\n    factor = models.FloatField(validators=[validators.MinValueValidator(0.0)])\n\nclass FoodDiaryEntryManager(models.Manager):\n    def get_queryset(self):\n        qset=models.Manager.get_queryset(self)\n        return qset.annotate(\n            qta=models.F("quantity")*models.F("measure_unit__factor"),\n            ratio=models.F("quantity")*models.F("measure_unit__factor")/100\n        ).annotate(\n             kcal=models.F("ratio")*models.F("product__kcal")\n        )\n\nclass FoodDiaryEntry(models.Model):\n    user = models.ForeignKey(User,on_delete=models.PROTECT)\n    time = models.DateTimeField(default=timezone.now)\n    product = models.ForeignKey(Product,on_delete=models.PROTECT)\n    measure_unit = models.ForeignKey(MeasureUnit,on_delete=models.PROTECT)\n    quantity = models.FloatField(validators=[validators.MinValueValidator(0.0)])\n    future = models.BooleanField(default=False)\n\n    objects=FoodDiaryEntryManager()\n\n    kcal          = models.FloatField(editable=False)\n    fat           = models.FloatField(editable=False)\n    saturated_fat = models.FloatField(editable=False)\n    carbohydrate  = models.FloatField(editable=False)\n    sugar         = models.FloatField(editable=False)\n    protein       = models.FloatField(editable=False)\n    alcohol       = models.FloatField(editable=False)\n    added_sugar   = models.FloatField(editable=False)\n    salt          = models.FloatField(editable=False)\n    sodium        = models.FloatField(editable=False)\n    potassium     = models.FloatField(editable=False)\n    fiber         = models.FloatField(editable=False)\n    water         = models.FloatField(editable=False)\n\n\n    def __str__(self): return str(self.product)\n\n    class Meta:\n        ordering = [ \'time\' ]\n\n    def save(self,*args,**kwargs):\n        self.kcal=self._kcal()\n        self.fat=self._fat()\n        self.carbohydrate=self._carbohydrate()\n        self.sugar=self._sugar()\n        self.protein=self._protein()\n        self.added_sugar=self._added_sugar()\n        self.alcohol=self._alcohol()\n        self.saturated_fat=self._saturated_fat()\n        self.salt=self._salt()\n        self.sodium=self._sodium()\n        self.potassium=self._potassium()\n        self.fiber=self._fiber()\n        self.water=self._water()\n        super(FoodDiaryEntry,self).save(*args,**kwargs)\n\n    def quantity_real(self):\n        return self.quantity*self.measure_unit.factor\n\n    def measure_unit_real(self):\n        return self.measure_unit.base\n\n    def _kcal(self): return self.product.kcal*self.quantity_real()/100.0\n    def _fat(self): return self.product.fat*self.quantity_real()/100.0\n    def _alcohol(self): return self.product.alcohol*self.quantity_real()/100.0\n    def _carbohydrate(self): return self.product.carbohydrate*self.quantity_real()/100.0\n    def _sugar(self): return self.product.sugar*self.quantity_real()/100.0\n    def _added_sugar(self): return self.product.added_sugar*self.quantity_real()/100.0\n    def _protein(self): return self.product.protein*self.quantity_real()/100.0\n    def _saturated_fat(self): return self.product.saturated_fat*self.quantity_real()/100.0\n    def _salt(self): return self.product.salt*self.quantity_real()/100.0\n    def _sodium(self): return self.product.sodium*self.quantity_real()/100.0\n    def _potassium(self): return self.product.potassium*self.quantity_real()/100.0\n    def _fiber(self): return self.product.fiber*self.quantity_real()/100.0\n    def _water(self): return self.product.water*self.quantity_real()/100.0\n\nclass WeightDiaryEntry(models.Model):\n    user = models.ForeignKey(User,on_delete=models.PROTECT)\n    time = models.DateTimeField(default=timezone.now)\n    weight = models.FloatField(validators=[validators.MinValueValidator(0.0)],verbose_name=\'weight (kg)\')\n    base = models.FloatField(editable=False)\n    need = models.FloatField(editable=False)\n\n    ## QUI\n    def save(self,*args,**kwargs):\n        # https://en.wikipedia.org/wiki/Harris%E2%80%93Benedict_equation\n        # Men \tBMR = (10 \xd7 weight in kg) + (6.25 \xd7 height in cm) - (5 \xd7 age in years) + 5\n        # Women BMR = (10 \xd7 weight in kg) + (6.25 \xd7 height in cm) - (5 \xd7 age in years) - 161 \n        self.need=2000\n        self.base=1000\n        #age=self.time-self.user.date_of_birth\n        year=self.time.year-self.user.date_of_birth.year\n        #age=self.time - datetime.datetime.combine(self.user.date_of_birth, datetime.time())\n        #year=age.days/365.0\n\n        print("SAVE",year)\n\n        base=(10*self.weight) + (6.25*self.user.height) - (5*year)\n        if self.user.gender=="male":\n            base+=5\n        else:\n            base-=161\n\n        self.base=base\n\n        print("SAVE",base)\n\n            \n        # self.base=base\n\n        if self.user.lifestyle=="sedentary":\n            need=1.53*base\n        elif self.user.lifestyle=="active":\n            need=1.76*base\n        else:\n            need=2.25*base\n\n        self.need=need\n        # print("SAVE",base,need)\n\n        super(WeightDiaryEntry,self).save(*args,**kwargs)\n\nclass Restaurant(AbstractName):  pass\n\nclass RestaurantDishQuerySet(models.QuerySet):\n    def with_kcal(self):\n        prods=RestaurantDishProduct.objects.filter(dish=models.OuterRef("pk")).values("dish")\n        total_prods=prods.annotate(total=models.Sum("kcal")).values("total")\n        return self.annotate(kcal=models.Subquery(total_prods))\n\nclass RestaurantDishManager(models.Manager):\n    def get_queryset(self):\n        qset=models.Manager.get_queryset(self)\n        prods=RestaurantDishProduct.objects.filter(dish=models.OuterRef("pk")).values("dish")\n        total_prods=prods.annotate(total=models.Sum("kcal")).values("total")\n        return qset.annotate(kcal=models.Subquery(total_prods))\n\nclass RestaurantDish(AbstractName):\n    restaurant = models.ForeignKey(Restaurant,on_delete=models.PROTECT)\n\n    objects=RestaurantDishManager.from_queryset(RestaurantDishQuerySet)()\n    \n    def __str__(self): \n        return "%s (%s)" %(str(self.name),str(self.restaurant))\n\n# class RestaurantDishProductQuerySet(models.QuerySet):\n#     def with_ratio(self):\n#         return self.annotate(\n#             qta=models.F("quantity")*models.F("measure_unit__factor"),\n#             ratio=models.F("quantity")*models.F("measure_unit__factor")/100\n#         )\n\n#     def with_kcal(self):\n#         return self.annotate(\n#             kcal=models.F("ratio")*models.F("product__kcal")\n#         )\n\nclass RestaurantDishProductManager(models.Manager):\n    def get_queryset(self):\n        qset=models.Manager.get_queryset(self)\n        return qset.annotate(\n            qta=models.F("quantity")*models.F("measure_unit__factor"),\n            ratio=models.F("quantity")*models.F("measure_unit__factor")/100\n        ).annotate(\n            kcal=models.F("ratio")*models.F("product__kcal")\n        )\n\nclass RestaurantDishProduct(models.Model):\n    dish = models.ForeignKey(RestaurantDish,on_delete=models.PROTECT)\n    product = models.ForeignKey(Product,on_delete=models.PROTECT)\n    measure_unit = models.ForeignKey(MeasureUnit,on_delete=models.PROTECT)\n    quantity = models.FloatField(validators=[validators.MinValueValidator(0.0)])\n\n    objects=RestaurantDishProductManager() #.from_queryset(RestaurantDishProductQuerySet)()\n\n\n    def __str__(self): return str(self.product)\n\n    def quantity_real(self):\n        return self.quantity*self.measure_unit.factor\n\nclass RecipeQuerySet(models.QuerySet):\n    def with_kcal(self):\n        prods=RecipeProduct.objects.filter(recipe=models.OuterRef("pk")).values("recipe")\n        total_prods=prods.annotate(total=models.Sum("kcal")).values("total")\n        return self.annotate(kcal=models.Subquery(total_prods))\n\nclass RecipeManager(models.Manager):\n    def get_queryset(self):\n        qset=models.Manager.get_queryset(self)\n        prods=RecipeProduct.objects.filter(recipe=models.OuterRef("pk")).values("recipe")\n        total_prods=prods.annotate(total=models.Sum("kcal")).values("total")\n        return qset.annotate(kcal=models.Subquery(total_prods))\n\n\nclass Recipe(AbstractName):\n    time = models.DateTimeField(default=timezone.now)\n    final_weight = models.PositiveIntegerField(default=0)\n    total_weight = models.PositiveIntegerField(editable=False)\n\n    objects=RecipeManager.from_queryset(RecipeQuerySet)()\n\n    class Meta:\n        ordering = [ "-time" ]\n    \n    def _total_weight(self):\n        total=0\n        for rp in self.recipeproduct_set.all():\n            total+=rp.quantity_real()\n        return total\n\n    def save(self,*args,**kwargs):\n        self.total_weight=self._total_weight()\n        if self.final_weight==0:\n            self.final_weight=self.total_weight\n        super(Recipe,self).save(*args,**kwargs)\n\nclass RecipeProductManager(models.Manager):\n    def get_queryset(self):\n        qset=models.Manager.get_queryset(self)\n        return qset.annotate(\n            qta=models.F("quantity")*models.F("measure_unit__factor"),\n            ratio=models.F("quantity")*models.F("measure_unit__factor")/100\n        ).annotate(\n            kcal=models.F("ratio")*models.F("product__kcal")\n        )\n\n\nclass RecipeProduct(models.Model):\n    recipe = models.ForeignKey(Recipe,on_delete=models.PROTECT)\n    product = models.ForeignKey(Product,on_delete=models.PROTECT)\n    measure_unit = models.ForeignKey(MeasureUnit,on_delete=models.PROTECT)\n    quantity = models.FloatField(validators=[validators.MinValueValidator(0.0)])\n\n    objects=RecipeProductManager()\n\n    def __str__(self): return str(self.product)\n\n    def quantity_real(self):\n        return self.quantity*self.measure_unit.factor\n\nclass FrequentDiaryEntry(models.Model):\n    product = models.ForeignKey(Product,on_delete=models.PROTECT)\n    measure_unit = models.ForeignKey(MeasureUnit,on_delete=models.PROTECT)\n    quantity = models.FloatField(validators=[validators.MinValueValidator(0.0)])\n\n    def __str__(self): return str(self.product)+" ("+str(self.quantity)+" "+str(self.measure_unit)+")"\n\n\n#####\n\n\nclass UsdaNndFoodGroup(AbstractName):\n    usda_id = models.CharField(max_length=1024)\n    \nclass UsdaNndFood(models.Model):\n    usda_id = models.CharField(max_length=1024)\n    food_group = models.ForeignKey(UsdaNndFoodGroup,on_delete=models.PROTECT)\n    long_description = models.CharField(max_length=1024)\n    short_description = models.CharField(max_length=1024)\n    common_name = models.CharField(max_length=1024)\n    manufacturer_name = models.CharField(max_length=1024)\n    survey = models.BooleanField()\n    refuse_desc = models.CharField(max_length=1024)\n    refuse_perc = models.FloatField(validators=[validators.MinValueValidator(0.0)])\n    scientific_name = models.CharField(max_length=1024)\n    nitrogen_factor = models.FloatField(validators=[validators.MinValueValidator(0.0)])\n    protein_factor = models.FloatField(validators=[validators.MinValueValidator(0.0)])\n    fat_factor = models.FloatField(validators=[validators.MinValueValidator(0.0)])\n    carbohydrate_factor = models.FloatField(validators=[validators.MinValueValidator(0.0)])\n\n    def __str__(self): return str(self.short_description)\n\nclass UsdaNndLangual(models.Model):\n    usda_id = models.CharField(max_length=1024)\n    description = models.CharField(max_length=1024)\n\n    def __str__(self): return str(self.description)\n\nclass UsdaNndFoodLangualRelation(models.Model):\n    food    = models.ForeignKey(UsdaNndFood,on_delete=models.PROTECT)\n    langual = models.ForeignKey(UsdaNndLangual,on_delete=models.PROTECT)\n    \n    def __str__(self): return str(self.langual.description)\n    \n', 9003, 9004, 'invalid continuation byte'),)
@carltongibson
Copy link
Member

This may be related to #411...

It's hard to see what could be the issue here. Can you reduce it to a minimal runnable example?

@chiara-paci
Copy link
Author

I suppose this can be triggered introducing a syntax error on a minimal "Hello World" asgi application and configuring a systemd service.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants