小编Jac*_*ack的帖子

MYSQL根据特定列选择多个列

我想做一个SELECT请求,根据PLATFORM值,设法获得2列VALUE(DESKTOP&MOBILE).

这是一个示例表:

+----+---------+------+----------+-------+
| ID | PROJECT | NAME | PLATFORM | VALUE |
+----+---------+------+----------+-------+
|  1 |       1 | Foo  | desktop  |     1 |
|  2 |       1 | Foo  | mobile   |    42 |
|  3 |       1 | Bar  | desktop  |     3 |
|  4 |       1 | Bar  | mobile   |    10 |
|  5 |       2 | Foo  | desktop  |     2 |
|  6 |       2 | Bar  | mobile   |     9 …
Run Code Online (Sandbox Code Playgroud)

mysql merge select group-by nested-select

5
推荐指数
1
解决办法
70
查看次数

当所有 futures 完成或取消时 futures.wait() 或 futures.as_completed() 被阻止

我有 futures.as_completed() 或 futures.wait() 的错误,当所有 Futures 完成或取消时,该错误将无限期地被阻止。

这里是重现的步骤:

提交了 的期货后,我正在等待或 的ThreadPoolExecutor.submit()期货。在另一个线程中,我调用with ,然后在同一进程中,我正在等待 Futures 超时完成。等待将在延迟过去后返回,并有 2 个列表:已完成的 Futures 和已取消的 Futures。没有更多待处理的期货。但是,主线程中的第一个(或)仍然处于阻塞状态。futures.as_completed()futures.wait()ThreadPoolExecutor.shutdown()cancel_futures=Trueas_completed()wait()

Python文档中,它是这样描述的return_when=ALL_COMPLETED

当所有期货完成或取消时,该函数将返回。

而对于as_completed()

返回[...] 完成的期货(已完成或取消的期货)。

这符合我的情况。这是一个错误还是我错过了什么?我尝试在同一线程中调用shutdown(),但它没有改变任何内容。


代码示例:

import signal
import time
from concurrent import futures
from concurrent.futures import Future, ALL_COMPLETED
from concurrent.futures import ThreadPoolExecutor
from typing import Dict, Set


class SubThreads:
    def __init__(self):
        self.running_futures_url: Dict[str, Future] = {}
        self.webpage_crawler_th_pool = ThreadPoolExecutor(2)

    def …
Run Code Online (Sandbox Code Playgroud)

python multithreading threadpoolexecutor

5
推荐指数
1
解决办法
1495
查看次数