简体   繁体   English

尝试从 python 中的 azure 数据块中的事件中心读取事件

[英]Trying to read events from event hub in azure databricks in python

I am trying to read data from event hubs.我正在尝试从事件中心读取数据。 I am sending twitter data as json through event hub sender.我通过事件中心发送器将 twitter 数据作为 json 发送。 When I am trying to read the data and append it in a list I am getting the following error.Where am I possibly wrong?当我尝试在列表中读取数据和 append 时,我收到以下错误。我可能错在哪里? below code:下面的代码:

        for tweet in ts.search_tweets_iterable(tso):
            print(tweet)
            sender.send(EventData(tweet))


try:
    receiver = client.add_receiver(CONSUMER_GROUP, PARTITION, prefetch=5000, offset=OFFSET)
    client.run()
    start_time = time.time()
    for event_data in receiver.receive(timeout=100):
        last_offset = event_data.offset
        last_sn = event_data.sequence_number
        messages.append(next(event_data.body))
        total += 1

I am getting the below error:我收到以下错误:

TypeError: 'dict' object is not an iterator类型错误:'dict' object 不是迭代器

As per the error message: TypeError: 'dict' object is not an iterator.根据错误消息: TypeError: 'dict' object 不是迭代器。

It means that you use a "dict" type instead of iterator.这意味着您使用“dict”类型而不是迭代器。 You should check in your code which "dict" type cause this error.您应该检查您的代码是哪个“dict”类型导致此错误。 Then you can use iter() function to convert the dict to iterator.然后您可以使用iter() function 将字典转换为迭代器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM