代码
mapConcurrently httpLBS requests
引发
ConnectionFailure Network.BSD.getProtocolByName: does not exist (no such protocol name: tcp))
在大约1k的请求之后。
答案 0 :(得分:5)
请求全部并行运行,并使进程耗尽文件描述符。使用
import ClassyPrelude
traverseThrottled :: (MonadMask m, MonadBaseControl IO m, Forall (Pure m), Traversable t) => Int -> (a -> m b) -> t a -> m (t b)
traverseThrottled concLevel action taskContainer = do
sem <- newQSem concLevel
let throttledAction = bracket_ (waitQSem sem) (signalQSem sem) . action
mapConcurrently throttledAction taskContainer
(如果您不使用ClassyPrelude
,请调整导入)
如果您使用流媒体备选方案,请确保您的等效httpLBS
消耗该请求。并且b
在所有领域都是严格的。