First off, I've read [1] and am not trying to convert twisted code
into blocking code (well, I WAS, but have reconsidered).

I've got Kivy code using twisted code without much problem, but really
hated defining many in-line functions/lambdas for simple 'assign the
result to a Kivy widget' style things. I'm now abstracting
twisted-related code into its own class (separate from kivy UI code).

My eventual aim is for Kivy-related code to be approximately:-

    val = doSomeCallRemoteCallHere(args)
    myWidget.text = val

The closest I'm able to come to that so far is for my function to be
decorated with @defer.inlineCallbacks which will then look like this

    val = yield doSomeCallRemoteCallHere(args)
    myWidget.text = val

Much better readability than my previous

    def put_val_in_widget(retval):
        myWidget.text = retval
    d = doSomeCallRemoteCallHere(args)
    d.addCallback(put_val_in_widget)

Is this as 'good' (for the subjective readability concern) as it gets?
I'm basically going for sufficient readability that my UI code can be
read by programmers stuck in a synchronous mindset.

[1] - http://glyf.livejournal.com/40037.html

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

Reply via email to