Tasks seem to be executed multiple times #4

Open
danpres14 opened this Issue Nov 1, 2012 · 4 comments

Comments

Projects
None yet
4 participants

I need to build a distributed worker system where a group's tasks are worked in serial fashion. This module looks to be exactly what I need; however, I am running into a problem where it looks like the task is being passed to the worker multiple times. Is this a known issue and if I were to spend the time to code an example, is this code active so that the issue can be fixed quickly?

Thanks,
-Dan

Owner

baoshan commented Feb 6, 2013

Could you reproduce that? I'm interested.

The module has been deployed with several projects and behaves good so far.

I see there's RedisMsgQueue, but still wish you could reproduce the problem anyway.

Contributor

henryoswald commented Mar 5, 2013

Hi, I ran into the same issue. I bet you were calling register multiple times on the same queue. What happens each time you call connect is you get a new instance of fairy so it basically acts like a singleton if you just do it the once at the top of your file. Perhaps this is not the best behavior as it caught out both of us but if you change your code to something like this it should fix the problem.

while worker_count-- > 0
    workerQueueRef = require('fairy').connect().queue(key)
    workerQueueRef.regist (stuff, callback)->
Owner

baoshan commented Mar 6, 2013

Hi, thanks for pointing out the trap! For now, reuse the fairy object is safe, but not the queue object:

fairy = require('fairy').connect()
while worker_count-- > 0
  fairy.queue(key).regist (stuff, callback) ->

I'll leave the issue open until our developing experience be improved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment