Error in spawn #438

Closed
cnaize opened this Issue Feb 12, 2014 · 2 comments

Projects

None yet

3 participants

@cnaize
cnaize commented Feb 12, 2014

I have this code:

upload_file('POST', []) ->
    [{_, _FileName, TempLocation, _Size, _Name} | _] = Req:post_files(),
    File = "1.txt",
    case filelib:is_regular(File) of
        true  -> Lines = get_files_diff(File, TempLocation);
        false -> Lines = get_files_cont(TempLocation)
    end,

    boss_mq:push("my-channel", "File uploaded!"),
    [spawn(cb_tracker_main_controller, process_lines, [X]) || X <- Lines],
    {output, "ok"}.

Here is my process_lines function:

process_lines(H) ->
    {Uid, _} = string:to_integer(string:substr(H, 9, 1)),
    DateTime = list_to_binary(string:substr(H, 11, 19)),
    {Type, _} = string:to_integer(string:substr(H, 33, 1)),
    {IdType, _} = string:to_integer(string:substr(H, 35, 1)),

    User = hd(boss_db:find(consumer, [{uiid, integer_to_binary(Uid)}])),
    Item = item:new(id, User:id(), DateTime, integer_to_binary(Type), integer_to_binary(IdType)),
    Item:save(),
    boss_mq:push("my-channel", "Item created!").

And I have an error:

[error] Error in process <0.508.0> on node 'cb_tracker@sonya' with exit value: {undef,[{cb_tracker_main_controller,process_lines,["        2       2013-12-10 21:56:09     1       1       2       0"],[]}]}

In console without ChicagoBooss everything is ok. There is the problem?

@mihawk
mihawk commented Feb 26, 2014

just do in your console m(cb_tracker_main_controller).
i guess you will see that cb_tracker_main_controller:process_lines/1 doesn't exist , because it is a parametized module.

i sugest you to move your fonction into a lib module into the folder /lib.
mihawk.

@danikp
Collaborator
danikp commented Oct 11, 2015

please re-open if problem is still persist

@danikp danikp closed this Oct 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment