Open andreikop opened 10 years ago
I'm glad to see somebody is finding the library useful! :)
However, can you please elaborate a bit on the purpose of such change? What would this CoroutineCancelled
exception add to the picture? What could you do that you cannot do now?
Let me also point out that finally:
is not the same as except GeneratorExit:
—the former will be executed no matter what; exept GeneratorExit
only when GeneratorExit
is raised.
All works fine. This is only about code readability.
You are right, that finally and except GeneratorExit
is not the same. I use except ..
to write logs 'Process finished successfully'.
But, catching GeneratorExit
looks not intuitive, I'm not sure if new guys who haven't read your post about @coroutine
would understand this code.
In your examples you use next piece of code:
I would say, that finally is also not very illustrative. How about adding exception
CouroutineCancelled
to the txcoroutine API and throwing it to generator function with http://docs.python.org/2/reference/expressions.html?highlight=throw#generator.throw? So, couroutine would look this way:You may also create alias
CoroutineCancelled
forGeneratorExit
in your library, and continue usinggenerator.close()
. In this case existing code, which uses txcoroutine, will not be broken.Thanks for the cool library!