[Twisted-Python] UDP with multiple connections

Simon Pickles sipickles at hotmail.com
Thu Oct 11 15:32:46 EDT 2007


My problem is my app needs to be a server to many clients (thru TCP - 
twisted.protocols.basic) but a client to a further server, to which it 
passes occasional information.

Is this possible through twisted, since I need two threads, one with the 
server reactor.run() and one with the client connection listenTCP()?

At present using UDP for the client connection, if I call reactor.run() 
after listenUDP(), I get:

Traceback (most recent call last):
  File "E:\Dev\Python\Lib\threading.py", line 460, in __bootstrap
    self.run()
  File "G:\_Dev\Gateway 20071011\gatewayClient.py", line 59, in run
    reactor.run()
  File "E:\Dev\Python\lib\site-packages\twisted\internet\posixbase.py", 
line 219, in run
    self.startRunning(installSignalHandlers=installSignalHandlers)
  File "E:\Dev\Python\lib\site-packages\twisted\internet\posixbase.py", 
line 215, in startRunning
    self._handleSignals()
  File "E:\Dev\Python\lib\site-packages\twisted\internet\posixbase.py", 
line 185, in _handleSignals
    signal.signal(signal.SIGTERM, self.sigTerm)
ValueError: signal only works in main thread

If I don't call reactor.run(), it works. I can still send and recieve. 
What then, is the role of the reactor? I thought it started the 
listening loop?

Thanks

Simon

Jean-Paul Calderone wrote:
> On Thu, 11 Oct 2007 19:24:02 +0100, Simon Pickles 
> <sipickles at hotmail.com> wrote:
>> [snip]
>
> Hi,
>
> http://twistedmatrix.com/projects/core/documentation/howto/servers.html
>
> Hope this helps,
>
> Jean-Paul
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
>




More information about the Twisted-Python mailing list