Interruptible promises?

76 views
Skip to first unread message

David Jeschke

unread,
Jul 31, 2013, 12:39:23 PM7/31/13
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?

Domenic Denicola

unread,
Jul 31, 2013, 4:21:59 PM7/31/13
to q-con...@googlegroups.com
We've started down this road a few times, but never got to somewhere we were that comfortable with. "Cancellation" is usually what we call it.

The latest work that I am happy with is https://github.com/promises-aplus/cancellation-spec/issues/6. There are other discussions in that same issue tracker about other possibilities.


From: q-con...@googlegroups.com [q-con...@googlegroups.com] on behalf of David Jeschke [djes...@gmail.com]
Sent: Wednesday, July 31, 2013 12:39
To: q-con...@googlegroups.com
Subject: [Q] Interruptible promises?

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?

--
You received this message because you are subscribed to the Google Groups "Q Continuum (JavaScript)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to q-continuum...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply all
Reply to author
Forward
0 new messages