Remove deprecated usage pkg_resources (#103)

List entry points using importlib.metadata (Python >=3.10) or
importlib-metadata>=3.6 (Python < 3.10)
This commit is contained in:
Rémy Pecqueur
2023-08-01 02:33:31 +02:00
committed by GitHub
parent 7fb7fca176
commit a08ef61ba5
3 changed files with 17 additions and 12 deletions
+8 -4
View File
@@ -1,16 +1,22 @@
import logging
import os
import sys
from copy import deepcopy
from multiprocessing import cpu_count
from signal import signal
from warnings import warn
import pkg_resources
from django.conf import settings
from django.utils.translation import gettext_lazy as _
from django_q.queues import Queue
# The "selectable" entry points were introduced in importlib_metadata 3.6 and Python 3.10.
if sys.version_info < (3, 10):
from importlib_metadata import entry_points
else:
from importlib.metadata import entry_points
# optional
try:
import psutil
@@ -276,9 +282,7 @@ if Conf.ERROR_REPORTER:
# iterate through the configured error reporters,
# and instantiate an ErrorReporter using the provided config
for name, conf in error_conf.items():
for entry in pkg_resources.iter_entry_points(
"djangoq.errorreporters", name
):
for entry in entry_points(group="djangoq.errorreporters", name=name):
Reporter = entry.load()
reporters.append(Reporter(**conf))
error_reporter = ErrorReporter(reporters)