Repository navigation
Description
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
- open a list of multiple stock items
- select all of them (more than ~5 in my case)
- 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)
Activity
matmair commentedon Mar 31, 2026
there is a hard cutoff for tasks of 90 seconds; is the print job taking longer?
simonkuehling commentedon Mar 31, 2026
the printing time for 20 labels itself can take longer potentially (not measured, but could be) because of a bit of latency between the inventree server and a remote networked brother printer - does the task runtime includes the rendering as well as the communication with the printer?
can i overwrite that timeout with an ENV variable, maybe?
simonkuehling commentedon Mar 31, 2026
I probably found the timeout in data/config.yaml:
should be worth a try to drastically increase it for testing (like 10min), right?
matmair commentedon Mar 31, 2026
yes it includes everything from data loading to rendering to the whole print time
yes try increasing it; we might want to disable retires and prolong timeouts on that job type
simonkuehling commentedon Mar 31, 2026
Ok - i changed the timeout and will observe if this fixes it for now.
I agree, if the runtime includes the full printing run it might be good to give these jobs way more time to spare. and retries should be disabled as well to avoid reprint-loops 👍
matmair commentedon Apr 1, 2026
@simonkuehling was your problem solved?
simonkuehling commentedon Apr 2, 2026
yes, it seems to work with the increased timeout for now!
SchrodingersGat commentedon Apr 4, 2026
I have dug into the background worker code, to see what is possible.
Custom Timeout
It is possible to set a custom timeout per call to
offload_taskCustom Retry Count
I do not see a way to specify this per task - you can only specify "max_attempts" globally:
django-q2/django-q2#114
matmair commentedon Apr 5, 2026
I think a good step to solve this would be to add a pretty long timeout to the print jobs issued by the brother plugin; i will look into that
github-actions commentedon Jun 5, 2026
This issue seems stale. Please react to show this is still important.
github-actions commentedon Aug 5, 2026
This issue seems stale. Please react to show this is still important.
fix: extend timeout for background label printing tasks
fix: extend timeout for background label printing tasks