typeerror:\uuu init\uuu()正好接受1个参数(给定2个)

neekobn8  于 2021-06-07  发布在  Kafka
关注(0)|答案(1)|浏览(413)

我试图在ubuntu中运行monasca persister组件,但是有一个与kafka相关的文件出错,我的kafka服务器运行良好。

Process Process-2:
commit_timeout=kafka_conf.max_wait_time_seconds)
File "/usr/local/lib/python2.7/dist-packages/monasca_common/kafka/consumer.py", line 92, in __init__
Traceback (most recent call last):
self._kafka = kafka.client.KafkaClient(kafka_url)
TypeError: __init__() takes exactly 1 argument (2 given)
File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(*self._args,**self._kwargs)
File "persister.py", line 126, in start_process
persister = Persister(kafka_config, cfg.CONF.zookeeper, respository)
File "/home/dpeuser/monasca-persister/monasca_persister/repositories/persister.py", line 42, in __init__
commit_timeout=kafka_conf.max_wait_time_seconds)
File "/usr/local/lib/python2.7/dist-packages/monasca_common/kafka/consumer.py", line 92, in __init__
self._kafka = kafka.client.KafkaClient(kafka_url)
TypeError: __init__() takes exactly 1 argument (2 given)
2016-08-31 12:05:55.245 28419 INFO __main__ [-] Received signal 17, beginning graceful shutdown.

所以,我检查了错误的文件,但我不能找出什么是错误的

class KafkaConsumer(object):
def __init__(self, kafka_url,
             zookeeper_url, zookeeper_path,
             group, topic,
             fetch_size=1048576,
             repartition_callback=None,
             commit_callback=None,
             commit_timeout=30):
    """Init
         kafka_url            - Kafka location
         zookeeper_url        - Zookeeper location
         zookeeper_path       - Zookeeper path used for partition
                                negotiation
         group                - Kafka consumer group
         topic                - Kafka topic
         repartition_callback - Callback to run when the Kafka consumer
                                group changes.  Repartitioning takes a
                                relatively long time so this is a good
                                time to flush and commit any data.
         commit_callback      - Callback to run when the commit_timeout
                                has elapsed between commits.
         commit_timeout       - Timeout between commits.
    """

    self._kazoo_client = None
    self._set_partitioner = None

    self._repartition_callback = repartition_callback

    self._commit_callback = commit_callback
    self._commit_timeout = commit_timeout

    self._last_commit = 0

    self._partitions = []

    self._kafka_group = group
    self._kafka_topic = topic
    self._kafka_fetch_size = fetch_size

    self._zookeeper_url = zookeeper_url
    self._zookeeper_path = zookeeper_path

    self._kafka = kafka.client.KafkaClient(kafka_url)

    self._consumer = self._create_kafka_consumer()
mf98qq94

mf98qq941#

这个 KafkaClient 类不接受任何位置参数。作为关键字参数传入配置:

self._kafka = kafka.client.KafkaClient(bootstrap_servers=kafka_url)

请参阅文档中链接的源代码,以查看接受哪些配置关键字及其默认值。许多相同的配置选项也为 KafkaConsumer 班级。

相关问题