Changes between Version 5 and Version 6 of FrequentlyAskedQuestions


Ignore:
Timestamp:
12/05/06 04:07:38 (15 years ago)
Author:
oubiwann
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FrequentlyAskedQuestions

    v5 v6  
    125125[http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.IReactorProcess.spawnProcess.html spawnProcess] defaults to clearing the environment of child processes as a security feature. You can either provide a dictionary with exactly the name-value pairs you want the child to use, or you can simply pass in {{{os.environ}}} to inherit the complete environment.
    126126
    127 === My Deferred or DeferredList never fires, so my program just mysteriously hangs! What's wrong? ===
     127=== My Deferred or !DeferredList never fires, so my program just mysteriously hangs! What's wrong? ===
    128128
    129129It really depends on what your program is doing, but the most common cause is this: it is firing -- but it's an error, not a success, and you have forgotten to add an [http://twistedmatrix.com/projects/core/documentation/howto/glossary.html#errback errback], so nothing happens. Always add errbacks!
     
    141141If you have blocking code that you want to use non-blockingly in Twisted, either rewrite it to be non-blocking, or run it in a thread. There is a convenience function, [http://twistedmatrix.com/documents/current/api/twisted.internet.threads.deferToThread.html deferToThread], to help you with the threaded approach -- but be sure to read [http://twistedmatrix.com/projects/core/documentation/howto/threading.html Using Threads in Twisted].
    142142
    143 === I get exceptions.ValueError: signal only works in main thread when I try to run my Twisted program! What's wrong? ===
     143=== I get {{{exceptions.ValueError: signal only works in main thread}}} when I try to run my Twisted program! What's wrong? ===
    144144
    145145The default reactor, by default, will install signal handlers to catch events like Ctrl-C, SIGTERM, and so on. However, you can't install signal handlers from non-main threads in Python, which means that {{{reactor.run()}}} will cause an error. Pass the {{{installSignalHandlers=0}}} keyword argument to {{{reactor.run}}} to work around this.
    146146
    147147=== I'm trying to stop my program with sys.exit(), but Twisted seems to catch it! How do I exit my program? ===
     148
     149Use {{{reactor.stop()}}} instead. This will cleanly shutdown the reactor.
     150
    148151=== How do I find out the IP address of the other end of my connection? ===
     152
     153The {{{.transport}}} object (which implements the [http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.ITransport.html ITransport] interface) offers a pair of methods named [http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.ITransport.getPeer.html getPeer] and [http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.ITransport.getHost.html getHost]. {{{getPeer}}} will give you a tuple that describes the address of the system at the other end of the connection. For example:
     154
     155{{{
     156#!python
     157class MyProtocol(protocol.Protocol):
     158    def connectionMade(self):
     159        print "connection from", self.transport.getPeer()
     160}}}
     161
    149162=== Why don't Twisted's network methods support Unicode objects as well as strings? ===
    150163== Perspective Broker ==