David Jeschke
unread,Jul 31, 2013, 12:39:23 PM7/31/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to q-con...@googlegroups.com
Has anyone done any work with interruptible promises? I'm thinking about the case where you have some long-running asynchronous processes managed by promises and want respond gracefully to Ctrl+C/SIGINT, SIGTERM, SIGHUP, SIGUSR1, etc. I've created a layer on top of Q where q.defer can take a callback function that is called in the case of an interrupt, where the callback is supposed to clean up and reject the deferred with a special interrupt error. I keep track of all of the interruptible promises and when a signal comes in the callbacks get called. I added interrupt-aware versions of q.all, q.delay, etc. I've also come across some use cases where it would be useful to be able to interrupt a specific promise. In my system any long-lived promises are interruptible and short-lived ones are ordinary uninterruptible Q promises. It seems to work pretty well but I'm sure I'm missing some things and I'd be a lot more comfortable if something like this were part of Q itself. Has anyone thought about this is detail?