Giter Club home page Giter Club logo

Comments (7)

mhenrixon avatar mhenrixon commented on August 18, 2024

Is that only for blocks? For a rescue ensure scenario in a method, the ensure part would only return something with an explicit return. Are blocks different?

from sidekiq-unique-jobs.

mhenrixon avatar mhenrixon commented on August 18, 2024

Try this in the console:

CleanShot 2023-04-13 at 13 08 03@2x

****

from sidekiq-unique-jobs.

mhenrixon avatar mhenrixon commented on August 18, 2024

If the ensure part would indeed return something it would say "pokus" not "hokus".

from sidekiq-unique-jobs.

dsander avatar dsander commented on August 18, 2024

In our case I believe this happened:

irb(main):015:0* block = lambda do
irb(main):016:0*   true
irb(main):017:0*   "i don't know the return value" if false
irb(main):018:0* ensure
irb(main):019:0*   false
irb(main):020:-> end
irb(main):021:-> pp block.call
nil
=> nil

If unlock succeeds everything works as you mentioned:

irb(main):022:0* block = lambda do
irb(main):023:0*   true
irb(main):024:0*   "i don't know the return value" if true
irb(main):025:0* ensure
irb(main):026:0*   false
irb(main):027:-> end
"i don't know the return value"
=> "i don't know the return value"

from sidekiq-unique-jobs.

dsander avatar dsander commented on August 18, 2024

So maybe a different approach to solve this would be

      def execute(&block)
        with_logging_context do
          executed = locksmith.execute do
            yield
          ensure
            callback_safely if locksmith.unlock
          end

          unless executed
            reflect(:execution_failed, item)
            call_strategy(origin: :server, &block)
          end
        end
      end

? To be honest I wasn't aware that the result of the ensure block isn't the return value of the block ๐Ÿ˜‰

from sidekiq-unique-jobs.

mhenrixon avatar mhenrixon commented on August 18, 2024

Ah now I see your problem doh ๐Ÿ™„

from sidekiq-unique-jobs.

dsander avatar dsander commented on August 18, 2024

Thank you!

from sidekiq-unique-jobs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.