【发布时间】:2021-02-21 22:04:34
【问题描述】:
我正在尝试访问 staticmethod 中的类实例,但我在这样做时遇到了困难。这是我的课:
class Worker:
def __init__(self, ch, method, properties, body):
self.ch = ch
self.method = method
self.properties = properties
self.body = body
@staticmethod
def receive_payload_and_validate_schema(body):
# some logic
return body
@staticmethod
def some_func(id_info, partner_params):
id_response = {}
# some logic
self.ch.basic_ack(delivery_tag=self.method.delivery_tag) # This is where the problem is
return id_response
@staticmethod
def another_func(body):
id_info = {} # assume it contains keys and values
partner_params = {} # assume it contains keys and values
# some logic
return Worker.some_func(id_info, partner_params)
如何在 some_func 静态方法中使用这个表达式 self.ch.basic_ack(delivery_tag=self.method.delivery_tag)?
【问题讨论】:
标签: python flask rabbitmq pika