All threads / Method returns true in a rails app controller, but returns false in resque worker when File.exists?

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Method returns true in a rails app controller, but returns false in resque worker when File.exists?

SarikaA asked in Rails

I want to pass the path this to a resque worker which will act upon this file. This worker is unable to find this file and the File.exists? Return a false even though the same method returns true in the controller class. This is happening intermittently and I assume there is a race condition. Any suggestions as to what could be the issue and how to handle it?

Please give me some advice...

Thanks in advance.

Try running your worker behind an after_commit callback. It might be because your worker started running even if the data hasn't persisted in your DB yet.

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 33,665+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.