Skip to content

label printing background task timeouts - labels get printed multiple times #11650

@simonkuehling

Description

@simonkuehling

Please verify that this bug has NOT been raised before.

  • I checked and didn't find a similar issue

Describe the bug*

When printing multiple stock item labels (inventree-brother-plugin with brother ethernet label printers) at once I often run into an issue that not all labels get printed, but the printjob is randomly repeated 2-3x.

I found a traceback regarding a timeout from the backgroud worker process that seems to match the time of printing - but I cannot wrap my head around the real cause of the error yet. any idea?

Steps to Reproduce

  1. open a list of multiple stock items
  2. select all of them (more than ~5 in my case)
  3. click "print labels" icon on top of the list

Expected behaviour

background job gets properly scheduled, only one label printed each, no labels missing

Deployment Method

Docker

Version Information

InvenTree-Version: 1.2.0 dev
Django Version: 5.2.8
Commit Hash: f72efb8
Commit Date: 2025-11-20
Commit Branch: null
Database: django.db.backends.postgresql
Debug-Mode: False
Deployed using Docker: True
Platform: Linux-6.1.0-rpi7-rpi-v8-aarch64-with-glibc2.41
Installer: DOC
Active plugins: [{"name":"InvenTreeBarcode","slug":"inventreebarcode","version":"2.1.0"},{"name":"BOM Exporter","slug":"bom-exporter","version":"1.1.0"},{"name":"InvenTree Exporter","slug":"inventree-exporter","version":"1.0.0"},{"name":"Part Parameter Exporter","slug":"parameter-exporter","version":"1.0.0"},{"name":"Part Stocktake Exporter","slug":"inventree-stocktake-exporter","version":"1.0.0"},{"name":"InvenTreeEmailNotifications","slug":"inventree-email-notification","version":"1.0.0"},{"name":"InvenTreeUINotifications","slug":"inventree-ui-notification","version":"1.0.0"},{"name":"InvenTreeCurrencyExchange","slug":"inventreecurrencyexchange","version":"1.0.0"},{"name":"InvenTreeMachines","slug":"inventree-machines","version":"1.0.0"},{"name":"InvenTreeLabel","slug":"inventreelabel","version":"1.1.0"},{"name":"InvenTreeLabelMachine","slug":"inventreelabelmachine","version":"1.0.0"},{"name":"InvenTreeLabelSheet","slug":"inventreelabelsheet","version":"1.0.1"},{"name":"DigiKeyBarcodePlugin","slug":"digikeyplugin","version":"1.0.1"},{"name":"LCSCBarcodePlugin","slug":"lcscplugin","version":"1.0.1"},{"name":"MouserBarcodePlugin","slug":"mouserplugin","version":"1.0.1"},{"name":"TMEBarcodePlugin","slug":"tmeplugin","version":"1.0.1"},{"name":"IPNAutoGenerator","slug":"ipnautogenerator","version":null},{"name":"Brother Labels","slug":"brother","version":"2.0.5"}]

Try to reproduce on the demo site

I did not try to reproduce

Is the bug reproducible on the demo site?

Not reproducible

Relevant log output

Task exceeded maximum timeout value (90 seconds) : Traceback (most recent call last):

File "/root/.local/lib/python3.11/site-packages/django_q/worker.py", line 103, in worker

res = f(*task["args"], **task["kwargs"])

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/local/lib/python3.11/contextlib.py", line 81, in inner

return func(*args, **kwds)

^^^^^^^^^^^^^^^^^^^

File "/home/inventree/src/backend/InvenTree/report/tasks.py", line 86, in print_labels

template.print(items, plugin, output=output, options=options)

File "/home/inventree/src/backend/InvenTree/report/models.py", line 779, in print

plugin.print_labels(self, output, items, request, printing_options=options)

File "/home/inventree/src/backend/InvenTree/plugin/builtin/labels/inventree_machine.py", line 102, in print_labels

offload_task(

File "/home/inventree/src/backend/InvenTree/InvenTree/tasks.py", line 258, in offload_task

_func(*args, **kwargs)

File "/home/inventree/src/backend/InvenTree/machine/registry.py", line 545, in call_machine_function

return registry.call_machine_function(machine_id, function, *args, **kwargs)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/inventree/src/backend/InvenTree/machine/registry.py", line 77, in wrapper

result = method(self, *args, **kwargs)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/inventree/src/backend/InvenTree/machine/registry.py", line 530, in call_machine_function

return func(machine, *args, **kwargs)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/inventree/src/backend/InvenTree/machine/machine_types/label_printer.py", line 82, in print_labels

self.print_label(machine, label, item, **kwargs)

File "/usr/local/lib/python3.11/site-packages/inventree_brother/brother_plugin.py", line 181, in print_label

usb_device = machine.get_setting("USB_DEVICE", "D")

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/inventree/src/backend/InvenTree/machine/machine_type.py", line 372, in get_setting

return MachineSetting.get_setting(

^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/inventree/src/backend/InvenTree/common/models.py", line 653, in get_setting

backup_value = cls.get_setting_default(key, **kwargs)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/inventree/src/backend/InvenTree/common/models.py", line 507, in get_setting_default

setting = cls.get_setting_definition(key, **kwargs)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/inventree/src/backend/InvenTree/machine/models.py", line 200, in get_setting_definition

kwargs['settings'] = machine_config.machine.driver_settings

^^^^^^^^^^^^^^^^^^^^^^

File "/home/inventree/src/backend/InvenTree/machine/models.py", line 89, in machine

return registry.get_machine(self.pk)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/inventree/src/backend/InvenTree/machine/registry.py", line 85, in wrapper

self._update_registry_hash()

File "/home/inventree/src/backend/InvenTree/machine/registry.py", line 473, in _update_registry_hash

self._hash = self._calculate_registry_hash()

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/inventree/src/backend/InvenTree/machine/registry.py", line 426, in _calculate_registry_hash

plugin_registry.update_plugin_hash()

File "/home/inventree/src/backend/InvenTree/plugin/registry.py", line 972, in update_plugin_hash

self.registry_hash = self.calculate_plugin_hash()

^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/inventree/src/backend/InvenTree/plugin/registry.py", line 1022, in calculate_plugin_hash

data.update(str(plug.is_active()).encode())

^^^^^^^^^^^^^^^^

File "/home/inventree/src/backend/InvenTree/plugin/plugin.py", line 179, in is_active

if self.is_mandatory():

^^^^^^^^^^^^^^^^^^^

File "/home/inventree/src/backend/InvenTree/plugin/plugin.py", line 459, in is_mandatory

config = self.plugin_config()

^^^^^^^^^^^^^^^^^^^^

File "/home/inventree/src/backend/InvenTree/plugin/plugin.py", line 173, in plugin_config

return registry.get_plugin_config(self.plugin_slug())

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/inventree/src/backend/InvenTree/plugin/registry.py", line 229, in get_plugin_config

cfg = PluginConfig.objects.filter(key=slug).first()

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/root/.local/lib/python3.11/site-packages/django/db/models/query.py", line 1106, in first

for obj in queryset[:1]:

File "/root/.local/lib/python3.11/site-packages/django/db/models/query.py", line 386, in __iter__

self._fetch_all()

File "/root/.local/lib/python3.11/site-packages/django/db/models/query.py", line 1954, in _fetch_all

self._result_cache = list(self._iterable_class(self))

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/root/.local/lib/python3.11/site-packages/django/db/models/query.py", line 126, in __iter__

obj = model_cls.from_db(

^^^^^^^^^^^^^^^^^^

File "/root/.local/lib/python3.11/site-packages/django/db/models/base.py", line 584, in from_db

new = cls(*values)

^^^^^^^^^^^^

File "/home/inventree/src/backend/InvenTree/plugin/models.py", line 118, in __init__

self.meta = {

^

File "/home/inventree/src/backend/InvenTree/plugin/models.py", line 119, in <dictcomp>

key: get_plugin_meta(key)

^^^^^^^^^^^^^^^^^^^^

File "/home/inventree/src/backend/InvenTree/plugin/models.py", line 111, in get_plugin_meta

result = getattr(plugin, name, None)

^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/inventree/src/backend/InvenTree/plugin/plugin.py", line 482, in package_path

return self.check_package_path()

^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/inventree/src/backend/InvenTree/plugin/plugin.py", line 474, in check_package_path

return cls.file().relative_to(settings.BASE_DIR)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/local/lib/python3.11/pathlib.py", line 728, in relative_to

if (root or drv) if n == 0 else cf(abs_parts[:n]) != cf(to_abs_parts):

^^^^^^^^^^^^^^^^^

File "/usr/local/lib/python3.11/pathlib.py", line 257, in casefold_parts

def casefold_parts(self, parts):

File "/root/.local/lib/python3.11/site-packages/django_q/timeout.py", line 15, in raise_timeout_exception

raise TimeoutException(

django_q.exceptions.TimeoutException: Task exceeded maximum timeout value (90 seconds)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIdentifies a bug which needs to be addressedpluginPlugin ecosystem

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions