Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Job: user on_exit callback is called twice #20

Closed
comfortablynick opened this issue Oct 15, 2020 · 1 comment
Closed

Job: user on_exit callback is called twice #20

comfortablynick opened this issue Oct 15, 2020 · 1 comment

Comments

@comfortablynick
Copy link

I am trying to run a job and analyze the return code to decide what to do. When I put a print() call in the on_exit callback, I see it prints twice and looks like different arguments are being supplied each time. Sometimes I get the code but other times I don't. Is this intended?

Example fn:

function job_test()
  local Job = require'plenary.job'
  local job = Job:new{
    command = "ls",
    on_exit = function(...)
      print(...)
    end,
  }
  job:start()
  job:shutdown()
end

It outputs:

table: 0x420071d0 nil nil
nil

If I had to guess, I'd say it's being called with self one of the times, but not the other.

@tjdevries
Copy link
Member

OK, I think I've fixed this with the latest commit.

I'd recommend using job:wait over job:shutdown though generally, since that's probably what you want to do (just guessing though, since I have no idea if that's what you're trying to actually do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants