Skip to content

Bug in dataflow? #478

@schneems

Description

@schneems

I tried using dataflow. Kept getting an error. Re-wrote to only use a future, and it worked fine. Was getting this error:

argumentError: Not all dependencies are IVars
/Users/richardschneeman/.gem/ruby/2.3.0/gems/concurrent-ruby-1.0.0/lib/concurrent/dataflow.rb:61:in `call_dataflow'
/Users/richardschneeman/.gem/ruby/2.3.0/gems/concurrent-ruby-1.0.0/lib/concurrent/dataflow.rb:40:in `dataflow_with'
/Users/richardschneeman/.gem/ruby/2.3.0/gems/concurrent-ruby-1.0.0/lib/concurrent/dataflow.rb:35:in `dataflow'
/Users/richardschneeman/Documents/projects/sprockets/lib/sprockets/manifest.rb:203:in `block in compile'
/Users/richardschneeman/Documents/projects/sprockets/lib/sprockets/manifest.rb:131:in `block (2 levels) in find'
/Users/richardschneeman/Documents/projects/sprockets/lib/sprockets/base.rb:76:in `find_all_linked_assets'
/Users/richardschneeman/Documents/projects/sprockets/lib/sprockets/manifest.rb:130:in `block in find'
/Users/richardschneeman/Documents/projects/sprockets/lib/sprockets/manifest.rb:129:in `each'
/Users/richardschneeman/Documents/projects/sprockets/lib/sprockets/manifest.rb:129:in `find'
/Users/richardschneeman/Documents/projects/sprockets/lib/sprockets/manifest.rb:164:in `compile'
/Users/richardschneeman/.gem/ruby/2.3.0/bundler/gems/sprockets-rails-ad4a43bd1bb1/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define'
/Users/richardschneeman/Documents/projects/sprockets/lib/rake/sprocketstask.rb:147:in `with_logger'
/Users/richardschneeman/.gem/ruby/2.3.0/bundler/gems/sprockets-rails-ad4a43bd1bb1/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define'
Tasks: TOP => assets:precompile

Here is the diff to get the program working

         if File.exist?(target)
           logger.debug "Skipping #{target}, already exists"
-          file_is_written = Concurrent.dataflow { }
         else
           logger.info "Writing #{target}"
-          file_is_written = Concurrent.dataflow { asset.write_to target }
+          file_is_written = Concurrent::Future.execute { asset.write_to target }
           concurrent_writers << file_is_written
         end
         filenames << asset.filename
@@ -198,7 +197,10 @@ module Sprockets
           logger.debug "Skipping #{target}.gz, already exists"
         else
           logger.info "Writing #{target}.gz"
-          concurrent_compressors << Concurrent.dataflow(file_is_written) { gzip.compress(target) }
+          concurrent_compressors << Concurrent::Future.execute do
+            file_is_written.wait if file_is_written
+            gzip.compress(target)
+          end
         end

Then below I make sure all the futures have executed:

concurrent_writers.each(&:wait)
concurrent_compressors.each(&:wait)

Does anything jump out at you as being off with the dataflow implementation?

Metadata

Metadata

Assignees

Labels

bugA bug in the library or documentation.not-appliedThe bug/enhacement was closed and not fixed/implemented.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions