Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

publish() takes at least 3 arguments (3 given)

I am working with ceilometer python API and publishing data to pubnub. not sure what is meant by this error.

This is the part of code that is causing the problem i think,

def init_Data(data, channel):
  cpu_sample = cclient.samples.list(meter_name ='cpu_util')
  for each in cpu_sample:
    timetamp = each.timestamp
    volume =  each.counter_volume
    volume_int = int(volume)
    data_volume ={'value': volume_int}
    data=json.dumps(data_volume)
    print (data)


pubnub.publish(channel='orbit_channel', callback= init_Datar)
like image 584
Imo Avatar asked Dec 05 '25 05:12

Imo


1 Answers

publish() takes at least 3 arguments (3 given)

Such a terrible error message! One point of confusion is that self is also counted as an argument, even if it's not explicitly provided.

So you need to provide 2 arguments. And you did! But you need to provide the 2 required arguments, while you only provided 1 required and 1 optional argument. Check the API docs for pubnub.publish() to see what you're missing.

like image 189
Daniel Darabos Avatar answered Dec 08 '25 09:12

Daniel Darabos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!