Erlang/ets: reset ets table after getting a “bad argument”?

前端 未结 2 2055
借酒劲吻你
借酒劲吻你 2021-01-05 06:54

I\'ve been learning how to use ets, but one thing that has bothered me is that, occasionally*, ets:match throws a bad argument… And, from them on,

2条回答
  •  梦谈多话
    2021-01-05 07:44

    Although I'm not 100% sure, this thread seems to answer your question. It appears that you're observing this behaviour in the shell. If so, two facts are interacting in a confusing way:

    1. An ets table is deleted as soon as its owning process dies.
    2. The erlang shell dies whenver it receives an exception and is silently restarted.

    So, when you get the first exception, the current shell process dies causing the ets table to be deleted, and then a new shell process is started for you. Now, when you try another ets:match, it fails because the table no longer exists.

提交回复
热议问题