I'm trying to run some unit tests on a Flask api built in python, but when importing the app in the setUp of the class, I'm getting this:
def setUp(self):
from app import OPERATIONS_CATALOG_SVC
test/common/operations/test_common_services.py:10:
app.py:12: in from uwsgi_tasks import TaskExecutor, task .venv/lib/python3.11/site-packages/uwsgi_tasks/init.py:2: in from uwsgi_tasks.tasks import (
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import inspect
import collections
import logging
import threading
import traceback
import calendar
from contextlib import contextmanager
from datetime import datetime, timedelta
import os
import six
import warnings
from uwsgi_tasks.utils import (
import_by_path,
get_function_path,
ProxyDict,
)
try:
# noinspection PyPep8Naming
from six.moves import cPickle as pickle
except ImportError:
import pickle
try:
import uwsgi
if uwsgi.masterpid() == 0:
E AttributeError: module 'uwsgi' has no attribute 'masterpid'
.venv/lib/python3.11/site-packages/uwsgi_tasks/tasks.py:31: AttributeError
Pip list:
aniso8601 9.0.1 asgiref 3.7.2 attrs 23.2.0 cb-common 1.14.87 certifi 2024.2.2 cffi 1.16.0 charset-normalizer 3.3.2 click 8.1.7 cloudant 2.13.0 contextvars 2.4 coverage 4.5.4 cryptography 41.0.4 deepdiff 5.8.1 Deprecated 1.2.14 dnspython 2.1.0 Flask 2.2.5 Flask-Executor 0.9.3 flask-restplus 0.12.1 flask-restx 1.0.5 idna 3.6 ijson 2.3 immutables 0.20 importlib-metadata 6.11.0 iniconfig 2.0.0 itsdangerous 2.0.1 Jinja2 3.1.2 jmespath 0.10.0 jsonschema 4.17.3 MarkupSafe 2.1.2 mock 3.0.5 mongomock 3.17.0 opentelemetry-api 1.20.0 opentelemetry-exporter-jaeger-thrift 1.20.0 opentelemetry-instrumentation 0.41b0 opentelemetry-instrumentation-aiohttp-client 0.41b0 opentelemetry-instrumentation-asgi 0.41b0 opentelemetry-instrumentation-elasticsearch 0.41b0 opentelemetry-instrumentation-fastapi 0.41b0 opentelemetry-instrumentation-flask 0.41b0 opentelemetry-instrumentation-pymongo 0.41b0 opentelemetry-instrumentation-requests 0.41b0 opentelemetry-instrumentation-wsgi 0.41b0 opentelemetry-sdk 1.20.0 opentelemetry-semantic-conventions 0.41b0 opentelemetry-util-http 0.41b0 ordered-set 4.1.0 packaging 23.2 path.py 10.1 pika 1.2.0 pip 23.2.1 pluggy 1.4.0 pycparser 2.21 pycryptodome 3.10.1 PyJWT 2.4.0 pymongo 3.11.4 pyrsistent 0.20.0 pytest 7.2.0 pytest-cov 2.6.1 pytest-html 4.0.0 pytest-metadata 2.0.0 pytest-mock 1.10.4 python-dotenv 0.8.2 pytz 2024.1 PyYAML 6.0.1 redis 5.0.0 requests 2.31.0 requests-mock 1.5.2 sentinels 1.0.0 setuptools 65.5.0 six 1.16.0 statsd 3.3.0 thrift 0.16.0 typing_extensions 4.9.0 urllib3 2.2.0 uWSGI 2.0.22 uwsgi-tasks 0.7.3 Werkzeug 3.0.1 wrapt 1.16.0 zipp 3.17.0
python version: Python 3.11.5
There may be name conflict somewhere. Make sure you do not name your file/folder with python package name.
Start from scratch and it should be fine.
masterpid()is available inuwsgipackage.Link to the document : https://uwsgi-docs.readthedocs.io/en/latest/API.html#uwsgi-masterpid
uwsgi.masterpid()