我正在尝试将 celery Beat Worker 和普通的 celery Worker 作为 docker 容器运行。我的任务是烧瓶应用程序。
普通的芹菜工作人员工作正常,但在beat工作人员
中出现以下错误[2024-08-07 09:57:24,692: INFO/MainProcess] mingle: searching for neighbors
[2024-08-07 09:57:25,413: INFO/Beat] beat: Starting...
[2024-08-07 09:57:25,416: ERROR/Beat] Process Beat
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/billiard-4.2.0-py3.11.egg/billiard/process.py", line 323, in _bootstrap
self.run()
File "/usr/local/lib/python3.11/site-packages/celery-5.4.0-py3.11.egg/celery/beat.py", line 718, in run
self.service.start(embedded_process=True)
File "/usr/local/lib/python3.11/site-packages/celery-5.4.0-py3.11.egg/celery/beat.py", line 634, in start
humanize_seconds(self.scheduler.max_interval))
^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/kombu/utils/objects.py", line 40, in __get__
return super().__get__(instance, owner)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/functools.py", line 1001, in __get__
val = self.func(instance)
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/celery-5.4.0-py3.11.egg/celery/beat.py", line 677, in scheduler
return self.get_scheduler()
^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/celery-5.4.0-py3.11.egg/celery/beat.py", line 667, in get_scheduler
aliases = dict(load_extension_class_names(extension_namespace))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/celery-5.4.0-py3.11.egg/celery/utils/imports.py", line 150, in load_extension_class_names
_entry_points = entry_points(group=namespace)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/importlib/metadata/__init__.py", line 1041, in entry_points
return SelectableGroups.load(eps).select(**params)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/importlib/metadata/__init__.py", line 476, in load
ordered = sorted(eps, key=by_group)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/importlib/metadata/__init__.py", line 1038, in <genexpr>
eps = itertools.chain.from_iterable(
^
File "/usr/local/lib/python3.11/importlib/metadata/_itertools.py", line 16, in unique_everseen
k = key(element)
^^^^^^^^^^^^
File "/usr/local/lib/python3.11/importlib/metadata/__init__.py", line 955, in _normalized_name
or super()._normalized_name
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/importlib/metadata/__init__.py", line 627, in _normalized_name
return Prepared.normalize(self.name)
^^^^^^^^^
File "/usr/local/lib/python3.11/importlib/metadata/__init__.py", line 622, in name
return self.metadata['Name']
^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/importlib/metadata/__init__.py", line 611, in metadata
or self.read_text('PKG-INFO')
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/importlib/metadata/__init__.py", line 939, in read_text
return self._path.joinpath(filename).read_text(encoding='utf-8')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/zipfile.py", line 2468, in read_text
with self.open('r', encoding, *args, **kwargs) as strm:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/zipfile.py", line 2434, in open
stream = self.root.open(self.at, zip_mode, pwd=pwd)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/zipfile.py", line 1579, in open
fheader = zef_file.read(sizeFileHeader)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/zipfile.py", line 786, in read
self._pos = self._file.tell()
^^^^^^^^^^^^^^^^^
OSError: [Errno 9] Bad file descriptor
我使用 python 3.11.9-slim 作为 celerybeatworker 的基础镜像
以下是容器中安装的软件包的版本
amqp==5.2.0
attrs==24.1.0
billiard==4.2.0
blinker==1.8.2
boto3==1.34.145
botocore==1.34.145
celery==5.4.0
certifi==2024.7.4
cffi==1.17.0
charset-normalizer==3.3.2
CIRAUtils==9.0.0
click==8.1.7
click-didyoumean==0.3.1
click-plugins==1.1.1
click-repl==0.3.0
cobble==0.1.4
cryptography==43.0.0
cssselect==1.2.0
dnspython==2.6.1
et-xmlfile==1.1.0
flasgger==0.9.7.1
Flask==3.0.2
Flask-Cors==4.0.1
Flask-JWT-Extended==4.6.0
Flask-PyMongo==2.3.0
gunicorn==22.0.0
idna==3.7
importlib_metadata==8.2.0
itsdangerous==2.2.0
Jinja2==3.1.4
jmespath==1.0.1
jsonschema==4.23.0
jsonschema-specifications==2023.12.1
kombu==5.3.7
lxml==5.2.2
mammoth==1.8.0
MarkupSafe==2.1.5
mistune==3.0.2
msal==1.30.0
numpy==2.0.1
openpyxl==3.1.5
packaging==24.1
pandas==2.2.2
prompt_toolkit==3.0.47
pycparser==2.22
pycryptodome==3.20.0
PyJWT==2.8.0
pymongo==4.8.0
pyquery==2.0.0
python-dateutil==2.9.0
pytz==2024.1
PyYAML==6.0.1
redis==5.0.7
referencing==0.35.1
requests==2.32.3
rpds-py==0.19.1
s3transfer==0.10.2
sentry-sdk==2.10.0
six==1.16.0
tzdata==2024.1
urllib3==2.2.2
vine==5.1.0
wcwidth==0.2.13
Werkzeug==3.0.3
xmltodict==0.12.0
zipp==3.19.2
CIRAUtils==9.0.0
是定制套餐
问题出在我的自定义 python 包CIRAUtils的安装上。我正在使用命令
python setup.py install
。
从 Python 3.11 开始,安装软件包的首选方法是使用
pip
或 build
等工具,而不是 python setup.py install
。
因此,我通过生成
wheel file
安装了自定义 python 包,并使用命令 .whl
安装了 pip install cutom-package.whl
。这样做解决了我的问题。