Hi Steven,

On February 13, 2017 at 9:24:03 AM, steven meiers (commercial...@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

_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to