Jeff-Lewis / cls-hooked

cls-hooked : CLS using AsynWrap or async_hooks instead of async-listener for node 4.7+

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The right way to force run with empty context?

Strate opened this issue · comments

Hi,

I'm implementing a queue system, using https://caolan.github.io/async/docs.html#queue

And I need to enforce each worker run with empty new context. I found this way:

cosnt ns = clsHooked.createNamespace("test");
function runInNewContext(fn) {
  return ns.bind(fn, {})()
}

Is this a best way to do this, or there is a better way?