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

database locked occasionally #261

Open
Alsan opened this issue Oct 31, 2022 · 0 comments
Open

database locked occasionally #261

Alsan opened this issue Oct 31, 2022 · 0 comments

Comments

@Alsan
Copy link

Alsan commented Oct 31, 2022

I'm trying to write a program to auto tag my collections. It'll call the tmsu through shell execution, then combining fd to loop through all files in my collections. It worked as expected, except the tmsu returns database locked error occasionally.

Here's my program fragment:

func runCommand(filename string, command string, ch chan output) {
  // fmt.Println(cmd)
  fields := strings.Fields(command)
  cmd := exec.Command(fields[0], fields[1:]...)
  out, err := cmd.CombinedOutput()
  ch <- output{out, err}
}

...

ch := make(chan output)
go runCommand(fn, cmd, ch)

select {
case <-time.After(2 * time.Second):
  errs.PrintToStdErrAndExit(fmt.Sprintf("timeout: %s", cmd))
case x := <-ch:
  if x.err != nil {
    errs.PrintToStdErrAndExit(fmt.Sprintf("error: %s", string(x.out)))
  } else {
    fmt.Println(fn)
  }
}

Any suggestion on optimizing the program?

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

1 participant