technoweenie / coffee-resque

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

'job' event, running async code

balgarath opened this issue · comments

I'm trying to run some code before every job(via the 'job' event), but part of the code I need to run is async. Of course, the block of code finishes running before the async call does - any way we could get a callback inside that event so that I can wait for my async call? Or is there an obvious way to run async code in these that I am missing?

in situations where sequentially ordering of logic is important I do one of two things: 1. include the logic in the job itself, 2. wrap that logic in another job and enqueue the dependent job on the 'success' event of the first job. of course this is problem specific and may not be helpful in your case.

I feel that the current behavior is correct. if resque was to pass a callback function as an arg on the event it would require all registered listeners to callback before proceeding.

@technoweenie thoughts?

@balgarath Were you able to resolve this?

I ended up putting the code into every single job I'm running...feels a little messy but its functional. Thanks for the responses.