We have been using python embedded via the C API and have used Twisted for various things. We have come across some strange behavior and I cannot figure out what is going on.
from twisted.internet import reactor from twisted.web.client import downloadPage
...
def fetchRepo(): global gameType, gameName, setupComplete, cp if (setupComplete): url = urlbase + "/" + gameType + "/" + gameName + "/repo.ini" print "url is : " + url d = downloadPage(url, "C:\svntest\gamerepo.ini") d.addCallback(downloadSuccess) d.addErrback(downloadFailure) #cp.readfp(open("C:\game-repo.ini")) else: print "urls not setup, throw errors etc." ...
This is an example of how we have been using downloadPage from twisted.web.client. I have no problems getting the example to work when I make a simple app or write the code into the intrepeter. But if I use it inside my app I get the user timeout below.
Unhandled error in Deferred: Traceback (most recent call last): Failure: twisted.internet.error.TimeoutError: User timeout caused connection failure.
Am I forgetting something trivial? The reactor is running as we use PB for database pooling. Can I not call downloadPage after a reactor is setup and connected?
James
On Thu, 4 Dec 2008 10:28:46 -0500, James Joplin thejayjay@gmail.com wrote:
We have been using python embedded via the C API and have used Twisted for various things. We have come across some strange behavior and I cannot figure out what is going on.
from twisted.internet import reactor from twisted.web.client import downloadPage
...
def fetchRepo(): global gameType, gameName, setupComplete, cp if (setupComplete): url = urlbase + "/" + gameType + "/" + gameName + "/repo.ini" print "url is : " + url d = downloadPage(url, "C:\svntest\gamerepo.ini") d.addCallback(downloadSuccess) d.addErrback(downloadFailure) #cp.readfp(open("C:\game-repo.ini")) else: print "urls not setup, throw errors etc." ...
This is an example of how we have been using downloadPage from twisted.web.client. I have no problems getting the example to work when I make a simple app or write the code into the intrepeter. But if I use it inside my app I get the user timeout below.
Unhandled error in Deferred: Traceback (most recent call last): Failure: twisted.internet.error.TimeoutError: User timeout caused connection failure.
Am I forgetting something trivial? The reactor is running as we use PB for database pooling. Can I not call downloadPage after a reactor is setup and connected?
Calling downloadPage after reactor.run is fine. I'd take a look at DNS and firewall settings for problems there.
Jean-Paul
Wow, I feel like an idiot now! I never thought to test that. Thank you so much!
Is there any reason DNS would work in a standalone python app and when I embed the library via the C API dns stops working? Is there a library I should import to fix that?
James
On Thu, Dec 4, 2008 at 10:43 AM, Jean-Paul Calderone exarkun@divmod.comwrote:
On Thu, 4 Dec 2008 10:28:46 -0500, James Joplin thejayjay@gmail.com wrote:
We have been using python embedded via the C API and have used Twisted for various things. We have come across some strange behavior and I cannot figure out what is going on.
from twisted.internet import reactor from twisted.web.client import downloadPage
...
def fetchRepo(): global gameType, gameName, setupComplete, cp if (setupComplete): url = urlbase + "/" + gameType + "/" + gameName + "/repo.ini" print "url is : " + url d = downloadPage(url, "C:\svntest\gamerepo.ini") d.addCallback(downloadSuccess) d.addErrback(downloadFailure) #cp.readfp(open("C:\game-repo.ini")) else: print "urls not setup, throw errors etc." ...
This is an example of how we have been using downloadPage from twisted.web.client. I have no problems getting the example to work when I make a simple app or write the code into the intrepeter. But if I use it inside my app I get the user timeout below.
Unhandled error in Deferred: Traceback (most recent call last): Failure: twisted.internet.error.TimeoutError: User timeout caused connection failure.
Am I forgetting something trivial? The reactor is running as we use PB for database pooling. Can I not call downloadPage after a reactor is setup and connected?
Calling downloadPage after reactor.run is fine. I'd take a look at DNS and firewall settings for problems there.
Jean-Paul
Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python