运行100 spawn时,gen_event.erl + proc_lib.erl出错(Erlang)

时间:2014-04-26 19:35:49

标签: erlang

我有文件" c:\ 1 \ 0.txt" 100个网址

我运行100个spawn

并有错误

(no error logger present) error: "Error in process <0.240.0> with exit value: {badarg,[{gen_event,send,2,[{file,\"gen_event.erl\"},{line,221}]},{proc_lib,exit_p,2,[{file,\"proc_lib.erl\"},{line,259}]}]}\n"

我的代码

-module(gsearch).
-compile(export_all).
-include("c:\\1\\ibrowse.hrl").

main() ->
    ibrowse:start(),
    {ok, Device} = file:open("c:\\1\\0.txt", read),
    read_each_line(Device).

read_each_line(Device) ->
    case io:get_line(Device, "") of
        eof ->
            file:close(Device);
        Line ->
            spawn(gsearch, url_get, [string:substr(Line, 1, length(Line) - 1)]),
            read_each_line(Device)
    end.

url_get(Url) ->
    UrlHTTP = lists:concat(["http://www.", Url]),
    case ibrowse:send_req(UrlHTTP, [], get, [], [], 10000) of
        {ok, "200", _Headers, Data} ->
            save(Data, Url);
        Rslt ->
            err
            % io:format(Rslt)
            % io:format("Request failed: ~p~n", [Rslt])
    end.

save(Data, Url) ->
    Filename = lists:concat(["c:\\d\\", Url]),
    io:format("<"), io:format(Filename), io:format(">~n"),
    {ok, IoDevice} = file:open(Filename, [write, binary]),
    file:write_file(Filename, Data, [append]),
    file:close(Filename).

if i ibrowse:send_req 1 urls - 好的,

但如果我ibrowse:send_req 100 urls it bad

什么错了?

0 个答案:

没有答案