Python多处理池.close和池.join类型错误:';非类型';对象不可调用
我得到了一个错误Python多处理池.close和池.join类型错误:';非类型';对象不可调用,python,django,python-multiprocessing,Python,Django,Python Multiprocessing,我得到了一个错误TypeError:“NoneType”对象不可在self.pool.join中调用,该对象由 特别是,在Django应用程序中运行数据库迁移或测试套件时会发生错误 我尝试过通过以下方式实现import-atexit并在\uuuu-init\uuuu中注册方法: atexit.register(self.pool.close) atexit.register(self.pool.join) ……但这不起作用 为什么在下面的代码的\uuu del\uuu方法中会出现这种类型错误,
TypeError:“NoneType”对象不可在self.pool.join中调用,该对象由
特别是,在Django应用程序中运行数据库迁移或测试套件时会发生错误
我尝试过通过以下方式实现import-atexit
并在\uuuu-init\uuuu
中注册方法:
atexit.register(self.pool.close)
atexit.register(self.pool.join)
……但这不起作用
为什么在下面的代码的\uuu del\uuu
方法中会出现这种类型错误,我如何避免它
import datetime
import json
import mimetypes
from multiprocessing.pool import ThreadPool
import os
import re
import tempfile
# python 2 and python 3 compatibility library
import six
from six.moves.urllib.parse import quote
from paapi5_python_sdk.configuration import Configuration
import paapi5_python_sdk
from paapi5_python_sdk import rest
from paapi5_python_sdk.auth.sig_v4 import AWSV4Auth
class ApiClient(object):
PRIMITIVE_TYPES = (float, bool, bytes, six.text_type) + six.integer_types
NATIVE_TYPES_MAPPING = {
'int': int,
'long': int if six.PY3 else long, # noqa: F821
'float': float,
'str': str,
'bool': bool,
'date': datetime.date,
'datetime': datetime.datetime,
'object': object,
}
def __init__(self,
access_key,
secret_key,
host,
region,
configuration=None,
header_name=None,
header_value=None,
cookie=None):
if configuration is None:
configuration = Configuration()
self.configuration = configuration
self.pool = ThreadPool()
self.rest_client = rest.RESTClientObject(configuration)
self.default_headers = {}
if header_name is not None:
self.default_headers[header_name] = header_value
self.cookie = cookie
# Set default User-Agent.
self.user_agent = 'paapi5-python-sdk/1.0.0'
self.access_key = access_key
self.secret_key = secret_key
self.host = host
self.region = region
def __del__(self):
self.pool.close()
self.pool.join()
... rest of module
你能展示一些你是如何导致这种行为发生的示例代码吗。另外,作为旁注,不建议在中发生行为。请看这个