On Fri, Apr 5, 2013 at 10:56 AM, Nicolas Grilly
<[email protected]> wrote:
> On Friday, April 5, 2013 5:40:54 AM UTC+2, Forrest L Norvell wrote:
>>
>> Realistically speaking, there's no way to write a general "async finally"
>> in Node. Side effects are just too pervasive, and while if you're careful
>> you can ensure that resources are properly cleaned up, it's not a problem
>> that can be automated.
>
>
> I read everywhere it's very difficult to write a kind of "async finally" in
> Node because side effects are too pervasive and resources will be leaked,
> etc.
>
> In that case, why Tornado strategy regarding error handling is so radically
> different [1]? It is also an async server. It is also based on a dynamic
> language very comparable to Python. But instead of crashing and restart the
> process after every unexpected error, they send an error page, close the
> request/response, and go on with the next loop.
>
> [1] http://www.tornadoweb.org/en/stable/overview.html#error-handling
>
> I would be very interested to understand why this strategy is okay for
> Tornado but is not okay for Node.
Isaac already explained it a few posts up. I'll replicate his example
here for posterity:
function doSomething(array) {
for (var i = 0; i < array.length; i++) {
mightThrow(array[i]);
}
}
In Python:
def do_something(items):
for item in items:
might_throw(item)
How many items have been processed after an exception? You don't know
unless you add *a lot* of error handling everywhere. That kind of
error handling is very easy to screw up and very difficult to debug.
(And you will screw up. I don't believe in infallible programmers.)
Tornado (and Python in general, async or not) are just as susceptible
to this issue as node.js is.
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.