[Twisted-Python] twisted eats the error

L. Daniel Burr ldanielburr at me.com
Mon Feb 13 09:56:53 MST 2017


Hi Steven,

On February 13, 2017 at 9:24:03 AM, steven meiers (commercials24 at yahoo.de) wrote:

hi,


there is a abvious error in the code at the end.
since i know next to nothing about threads i thought maybe a print
statement in the code that is actually doing the work would give me
some pointers.

if im not mistaken, it is:
def callWithContext in python/context.py


as it turns out it does output nothing so i went back the call chain
until it prints something.
now im in:
internet/threads.py def deferToThreadPool

but even there, printing the argument f prints nothing?
isnt that the first method that is called from my code?


Sorry, your code example and your explanation don’t make clear what you expect to happen, and when.  When you say “the first method that is called from my code”, are you referring to  aSillyBlockingMethod, or runEverySecond?  In the deferToThread case, you are calling the former; in the task.LoopingCall case, you are calling the latter.

If your intent is to trigger the strftime exception as a consequence of your call to deferToThread, then you would need to either add runEverySecond to the callback chain, or move the call to strftime into the aSillyBlockingMethod call.

Example:

# this will "sleep" for x seconds
d = threads.deferToThread(aSillyBlockingMethod, 'some argument’)
d.addCallback(runEverySecond)
d.addCallback(printResult)
d.addErrback(printError)

Hope this helps,

L. Daniel Burr

-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20170213/ae101b51/attachment-0002.html>


More information about the Twisted-Python mailing list