python - exceptions raised from within a urlfetch callback -


When an async urlfetch callsback and calls within a tasklet, it seems that Do not promote the wrapping work within the exception callback.

Example code:

  def cb (): Increase exception, 'just one test' rpc = urlfetch.create_rpc (callback = CB) @ ndb.tasklet def t ( ): Try: feedback = yield except urlfetch.make_fetch_call (rpc, 'http: // ...'): print 'an error occurred' raise nndb.Return t () .get_result ()  

In the code above, executed by the dev server, "just a test" does not get caught in the exceptions of the workplace; To wit. Instead of an error message, the output is being given to the console as a "me one exam" exception.

If there is a general urlfetch exception related to make_fetch_call (such as in the case of a bad URL DownloadError ), It is being handled properly.

Is there a way to capture callback-exception exceptions inside the taskless like this? Or maybe this behavior should be considered a bug?

Thank you.

We designed this to be described correctly.

During reading the code, you will get lots of benefits from reading comments and cross-referencing with docs.

Some misleading aspects of this were the fact that NDB worklets actually use exceptions to indicate return values ​​(even if you succeed, you raise NNDB. Return (true) < / Code>, and the fact that the exceptions need to be caught in the callback when we return the wait () at rpc by t () Called the object. , while the exception to the url fetch needs to be caught in t () That is, when we do yield RPCMK_fetchack () , there may be a way to use Rpc.check_success (), but it will be to find out about your hacking.

I hope you find the source useful, and I hope that you have a lesson about avoiding the use of an exception to indicate that ... the generator is done ...

< / Div>

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -