Re: [Twisted-Python] Twisted-Python Digest, Vol 78, Issue 15

Sent from my HTC on the Now Network from Sprint! ----- Reply message ----- From: twisted-python-request@twistedmatrix.com Date: Fri, Sep 10, 2010 12:09 pm Subject: Twisted-Python Digest, Vol 78, Issue 15 To: <twisted-python@twistedmatrix.com> Send Twisted-Python mailing list submissions to twisted-python@twistedmatrix.com To subscribe or unsubscribe via the World Wide Web, visit http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python or, via email, send a message with subject or body 'help' to twisted-python-request@twistedmatrix.com You can reach the person managing the list at twisted-python-owner@twistedmatrix.com When replying, please edit your Subject line so it is more specific than "Re: Contents of Twisted-Python digest..." Today's Topics: 1. Re: Strange error: SQL-Server tries to rollback (Paul Goins) 2. reactor for both udp and tcp/ timer issue (belk Dj) 3. Re: twisted cred: why does avatarId need to be a str? (Laurens Van Houtven) 4. Re: reactor for both udp and tcp/ timer issue (Pantelis Theodosiou) ---------------------------------------------------------------------- Message: 1 Date: Sat, 11 Sep 2010 01:39:13 +0900 From: Paul Goins <general@vultaire.net> Subject: Re: [Twisted-Python] Strange error: SQL-Server tries to rollback To: twisted-python@twistedmatrix.com Message-ID: <4C8A5F31.8020305@vultaire.net> Content-Type: text/plain; charset=UTF-8; format=flowed Thanks for the code example. I can't offer to take this work over, but maybe I can make a comment. There's one part that stands out to me.
It seems like maybe you have a misunderstanding about how Deferreds generally work in Twisted. (Been there myself.) Basically, the above try/except block won't work to catch errors from most Deferreds... well, at least not without some extra magic. You really should read the Deferred section of the Twisted documentation to understand how errors are handled. Docs are here: http://twistedmatrix.com/documents/current/core/howto/defer.html ---- Basically, to "fix" the above code's error catching, you have two choices: 1. You can add an errback to the deferred. This is the "standard" Twisted way, and would replace the try/except block entirely. 2. You can use the @inlineCallbacks decorator (from twisted.internet.defer), and yield on the Deferred. This is easier, and it allows try/except blocks, but there's some gotchas. inlineCallbacks is what I used when I was learning Twisted, and you may want to try that for now. But please understand that it hides details about how Deferreds and callbacks really work. When you find time, read the Deferred docs. ---- Best of luck, - Paul Goins ------------------------------ Message: 2 Date: Fri, 10 Sep 2010 16:55:01 +0000 (GMT) From: belk Dj <d_belkhiter@yahoo.fr> Subject: [Twisted-Python] reactor for both udp and tcp/ timer issue To: twisted-python@twistedmatrix.com Message-ID: <228404.72208.qm@web24406.mail.ird.yahoo.com> Content-Type: text/plain; charset="utf-8" I need to communicate with servers over tcp and also communicate with other servers over udp. It seems not possible to launch two reactor objects one for tcp and one for udp. The code after a reactor.run is not called. How can this can be solved ? One more thing that deals with timer. When i send a message to a server if after some time i don't get an acknowledge i re send the message. And that x times. To do that i use Timer. When i send the message i start the timer if the acknowledge comes before the timeout i cancel the timer. If i don't receive this acknwledge in time i cancel the timer i re send the previous message and i re start the timer. In this two cases the program fails with the message the timer is still started. What is the issue ? Regards
participants (1)
-
lance.barisdale@gmail.com