Hi to all of you, I;m trying to impleting hostname resolution in a program that aimed to exchange UDP packets with his peers. What I do is add the two lines: dd = reactor.resolve(IP) dd.addCallback(self.call, distPort, password, destroy) To my program, but when I do that, I don't reach the call function. Seems like something would be missing. Does anyone have a clue? Cheers! Raphael
Raphael Arbuz wrote:
I;m trying to impleting hostname resolution in a program that aimed to exchange UDP packets with his peers.
What I do is add the two lines: dd = reactor.resolve(IP) dd.addCallback(self.call, distPort, password, destroy)
To my program, but when I do that, I don't reach the call function. Seems like something would be missing. Does anyone have a clue?
Yes, we do. What is missing is the rest of your program; that is, the parts that contain the bug. You owe the Oracle a bottle of crystal ball polish[1]. [1] You ain't an old beard if you don't know what that refers to.[2] [2] Yes, the grovel _was_ insufficient.
Sorry, here is a more complete listing of the part that could help: import wx from threading import Thread from twisted.internet import reactor from twisted.python import threadable from twisted.internet.defer import maybeDeferred, Deferred from twisted.internet import defer from time import sleep from time import time from communication import Communication from twisted.internet.task import LoopingCall from twisted.internet.protocol import DatagramProtocol import sys, traceback import audio import Queue import ConnectionManager class TwistedThread(Thread, DatagramProtocol): def __init__(self, appliClass, fileID, queue): Thread.__init__(self) # initialize the thread self.appliClass = appliClass self.fileID = fileID self.queue = queue def run(self): """after the thread is launched""" threadable.init(1) self.waitForCalls() while 1: msg = self.queue.get(1) if msg[0]=="call": self.resolve(IP = msg[1], password = msg[2]) break def waitForCalls(self): """open MAX_NB_CORRESPONDENTS ports to listen to incoming connections""" print "waiting for calls" for counter in range(self.appliClass.MAX_NB_CORRESPONDENTS): correspondent = ConnectionManager.ConnectionManager(self, self.sendPointer, False) try: reactor.listenUDP(8000+counter, self.correspondents[counter]) except: pass reactor.run(installSignalHandlers=0) def resolve(self, IP, distPort= 8000, password = "", destroy = False): print "on res" dd = reactor.resolve(IP) dd.addCallback(self.call, distPort, password, destroy) def call(self, IP, distPort = 8000, password = "", destroy = False): print "res done" """place a phone call""" print "Calling the IP " + str(IP) + " on port " + str(distPort) self.confPassword = password #set the conference password .... Hope it is clearer. Thanks a lot for your time Raphael ----- Original Message ----- From: "Tommi Virtanen" <tv@twistedmatrix.com> To: "Discussion of twisted.web, Nevow, and Woven" <twisted-web@twistedmatrix.com> Sent: Wednesday, August 24, 2005 6:15 PM Subject: Re: [Twisted-web] resolving a hostname problem
Raphael Arbuz wrote:
I;m trying to impleting hostname resolution in a program that aimed to exchange UDP packets with his peers.
What I do is add the two lines: dd = reactor.resolve(IP) dd.addCallback(self.call, distPort, password, destroy)
To my program, but when I do that, I don't reach the call function. Seems like something would be missing. Does anyone have a clue?
Yes, we do.
What is missing is the rest of your program; that is, the parts that contain the bug.
You owe the Oracle a bottle of crystal ball polish[1].
[1] You ain't an old beard if you don't know what that refers to.[2]
[2] Yes, the grovel _was_ insufficient.
_______________________________________________ Twisted-web mailing list Twisted-web@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
On Wed, 24 Aug 2005 18:28:34 +0100, Raphael Arbuz <raphaelarbuz@netcourrier.com> wrote:
Sorry, here is a more complete listing of the part that could help:
The program calls functions from the wrong thread. Almost every single Twisted API may only be invoked from the reactor thread. Why are you using threads at all? Most programs don't need them. Jp
Hi Jp, thanks for your answer but what do you mean byt the "wrong" thread? this one is the one where all my reactor things are. Thanks Raph ----- Original Message ----- From: "Jp Calderone" <exarkun@divmod.com> To: <Discussion@netcourrier.com>; <of@netcourrier.com>; <twisted.web@netcourrier.com>; <Nevow@netcourrier.com>; "and Woven" <twisted-web@twistedmatrix.com> Sent: Thursday, August 25, 2005 6:31 AM Subject: Re: [Twisted-web] resolving a hostname problem
On Wed, 24 Aug 2005 18:28:34 +0100, Raphael Arbuz <raphaelarbuz@netcourrier.com> wrote:
Sorry, here is a more complete listing of the part that could help:
The program calls functions from the wrong thread. Almost every single Twisted API may only be invoked from the reactor thread.
Why are you using threads at all? Most programs don't need them.
Jp
_______________________________________________ Twisted-web mailing list Twisted-web@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
Hello, Techno Turkey now has a blog of his own dedicated to better documentation for Twisted: http://tturkey.blogspot.com/ Best wishes, Lloyd
participants (4)
-
Jp Calderone
-
lloyd@paisite.com
-
Raphael Arbuz
-
Tommi Virtanen