RabbitMQ如何pika.adapters.blocking_连接.BlockingConnection.process_data_事件作品?

2024-04-24 23:27:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用python2.7和pika0.10.0并试图理解如何使用pika.adapters.blocking_connection.BlockingConnection.process_data_events。从doc

Will make sure that data events are processed. Dispatches timer and channel callbacks if not called from the scope of BlockingConnection or BlockingChannel callback. Your app can block on this method.

如果我们也看看参数:

Parameters: time_limit (float) – suggested upper bound on processing time in seconds. The actual blocking time depends on the granularity of the underlying ioloop. Zero means return as soon as possible. None means there is no limit on processing time and the function will block until I/O produces actionalable events. Defaults to 0 for backward compatibility. This parameter is NEW in pika 0.10.0.

我的理解是,调用process_data_events(time_limit=2)最多会阻塞2秒,如果同时发生了一个事件(例如,我们在一个通道上接收到一条消息),该事件将被处理;如果响应该事件而调用的回调耗时超过2秒,它将运行到完成,process_data_events(time_limit=2)将返回,可能在2秒之后秒。在

行为是否正确?在


Tags: andofthedatatimeon事件blocking