I have a Flow setup that does a port scan on localhost to catch anything I currently have running:
range
|> Flow.from_enumerable()
|> Flow.partition()
|> Flow.map(fn port ->
%URI{
host: host,
path: "/status",
port: port,
scheme: "http"
}
|> URI.to_string()
|> IO.inspect() # <-- only here for troubleshooting, issue persists without it
|> Req.get(retry: false)
|> assign(port)
end)
|> Flow.reject(fn response -> Enum.empty?(response) end)
...
Whether or not I use Flow.partition()
doesn’t seem to have an effect on it, but the IO.inspect()
seems to be printing out 24 items at a time with a delay of about one second between printing. Putting Flow.from_enumerable(max_demand: 1)
(something I saw on StackOverflow) doesn’t do anything to speed it up either.
When I run this same code on Ubuntu, the process completes in less than half a second. Is this an issue with how Windows allocates processes? Has anyone else experienced this with Flow? Or is this just poorly written code that Flow doesn’t know what to do with?