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

Bug when queued functions return both nil and non-nil values #98

Open
aschoenauer-sebag opened this issue Jul 17, 2017 · 1 comment
Open

Comments

@aschoenauer-sebag
Copy link

Hi,

Here is the code snippet that reproduces the bug:

local Threads = require 'threads'
Threads.serialization('threads.sharedserialize')
opt={}
opt.nDonkeys= 2
do -- start K datathreads (donkeys)
   if opt.nDonkeys > 0 then
      local options = opt -- make an upvalue to serialize over to donkey threads
      donkeys = Threads(
         opt.nDonkeys,
         function(threadid)
            require 'torch'
         end,

         function()
         end
      );
   else -- single threaded data loading. useful for debugging
      donkeys = {}
      function donkeys:addjob(f1, f2) f2(f1()) end
      function donkeys:terminate() end
   end
end

for k=1,10 do
    donkeys:addjob(
           function()
               local var1
               local var2 = 2
               if __threadid==1 then var1 = 1 end
               return var1, var2
           end,
                   function(var1, var2) print(var1, var2) end)
end
donkeys:terminate()

With opt.nDonkeys=2 we get:

t7> dofile('sandbox.lua' )
1	2	
nil	nil	
1	2	
nil	nil	
1	2	
nil	nil	
1	2	
1	2	
1	2	
nil	nil	

when I think it's reasonable to be expecting

t7> dofile('sandbox.lua' )
1	2	
nil	2	
1	2	
nil	2	
1	2	
nil	2	
1	2	
1	2	
1	2	
nil	2	

If this was done on purpose I would be curious to know why.

@farleylai
Copy link

I just encountered this bug by returning multiple variables with nils in between. Unfortunately, most development effort seems to move to pytorch.

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