调度程序关闭流警告

时间:2018-11-27 21:13:09

标签: python dask dask-distributed

我的笔记本电脑上有一个定期批处理作业。代码如下:

client = Client()
print(client.scheduler_info())
topic='raw_data'
start = datetime.datetime.now()
delta = datetime.timedelta(minutes=2)
while True:
    end = start + delta
    if end <= datetime.datetime.now():
        start = end
        print('It\'s time to run the analysis for the 2 mins')
        data = get_data_from_parquet('raw_data_fast_par.par', start=start, end=end)
        metrics = [Metric1(), Metric2(), Metric3()]
        print(data.npartitions)
        channels = data.groupby(['col1', 'col2', 'col3'])
        for metric in metrics:
            features = metric.map_job(channels, start, end)
            print(features.count().compute())

简而言之,我每两分钟对数据进行某种类型的分析,然后从镶木地板文件中读取数据,以进行向下日期过滤。这是一个测试,所以我知道现在没有多大意义了。 我在终端上收到以下警告。有人可以解释为什么会发生这种情况(如果很重要)以及如何避免这种情况?

distributed.comm.tcp - WARNING - Closing dangling stream in <TCP local=tcp://127.0.0.1:55448 remote=tcp://127.0.0.1:42197>

1 个答案:

答案 0 :(得分:2)

我不知道实际的问题是什么,但是您可能会在完成后尝试完全关闭本地集群,也许可以使用Client作为上下文管理器。

with Client() as client:
    ...