[Twisted-Python] simple multicast beacon problem ...
Darran Edmundson
darran.edmundson at anu.edu.au
Mon Apr 11 21:29:11 MDT 2005
I'm relatively new to Twisted and am struggling to create a multicast
beacon with the application framework. This beacon simply sends out
a datagram every second, no listening at all. I've appended a short sample
program and traceback to this email in the hope that someone can
point out the presumably simple usage error. For the life of me I can't
spot it. Here's the last bit of the traceback:
2005/04/12 13:15 EST [-] p = udp.MulticastPort(port, protocol,
interface, maxPacketSize, self)
2005/04/12 13:15 EST [-] File
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/twisted/internet/udp.py",
line 66, in __init__
2005/04/12 13:15 EST [-] assert isinstance(proto,
protocol.DatagramProtocol)
2005/04/12 13:15 EST [-] AssertionError
A quick debug shows that proto is HeartBeatFactory rather than its class
attribute protocol.
Any help is much appreciated.
Cheers,
Darran
--
Darran Edmundson (darran.edmundson at anu.edu.au)
ANU Supercomputer Facility Vizlab
Australian National University, Canberra, ACT 2600
tel: +61 2 6125-0517 fax: +61 2 6125-5088
------------------------------------- application.py
---------------------------------------------------
from twisted.internet import protocol, reactor
from twisted.internet import threads
from twisted.application import internet, service
class HeartBeat(protocol.DatagramProtocol):
def start_protocol(self):
self.send_datagram()
def send_datagram(self):
self.transport.write("message",(self.factory.group,self.factory.port))
self.reactor.callLater(1,self.send_datagram)
class HeartBeatFactory(protocol.ServerFactory):
protocol = HeartBeat
def __init__(self,group,port):
self.group = group
self.port = port
factory = HeartBeatFactory("234.32.23.1", 9999)
application = service.Application('HeartBeat')
service = internet.MulticastServer(9999, factory, interface='0.0.0.0')
service.setServiceParent(application)
------------------------------------- traceback
---------------------------------------------------
$ python twistd.py -noy application.py
2005/04/12 13:15 EST [-] Log opened.
2005/04/12 13:15 EST [-] twistd 1.1.1 (/usr/bin/python 2.3.0) starting up
2005/04/12 13:15 EST [-] reactor class:
twisted.internet.default.SelectReactor
2005/04/12 13:15 EST [-] Loading application.py...
2005/04/12 13:15 EST [-] Loaded.
2005/04/12 13:15 EST [-] Traceback (most recent call last):
2005/04/12 13:15 EST [-] File
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/twisted/scripts/twistd.py",
line 192, in ?
2005/04/12 13:15 EST [-] run()
2005/04/12 13:15 EST [-] File
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/twisted/scripts/twistd.py",
line 188, in run
2005/04/12 13:15 EST [-] app.run(runApp, ServerOptions)
2005/04/12 13:15 EST [-] File
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/twisted/application/app.py",
line 200, in run
2005/04/12 13:15 EST [-] runApp(config)
2005/04/12 13:15 EST [-] File
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/twisted/scripts/twistd.py",
line 179, in runApp
2005/04/12 13:15 EST [-] startApplication(config, application)
2005/04/12 13:15 EST [-] File
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/twisted/scripts/twistd.py",
line 163, in startApplication
2005/04/12 13:15 EST [-]
service.IService(application).privilegedStartService()
2005/04/12 13:15 EST [-] File
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/twisted/application/service.py",
line 188, in privilegedStartService
2005/04/12 13:15 EST [-] service.privilegedStartService()
2005/04/12 13:15 EST [-] File
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/twisted/application/internet.py",
line 53, in privilegedStartService
2005/04/12 13:15 EST [-] self._port = self._getPort()
2005/04/12 13:15 EST [-] File
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/twisted/application/internet.py",
line 68, in _getPort
2005/04/12 13:15 EST [-] return getattr(reactor,
'listen'+self.method)(*self.args, **self.kwargs)
2005/04/12 13:15 EST [-] File
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/twisted/internet/default.py",
line 210, in listenMulticast
2005/04/12 13:15 EST [-] p = udp.MulticastPort(port, protocol,
interface, maxPacketSize, self)
2005/04/12 13:15 EST [-] File
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/twisted/internet/udp.py",
line 66, in __init__
2005/04/12 13:15 EST [-] assert isinstance(proto,
protocol.DatagramProtocol)
2005/04/12 13:15 EST [-] AssertionError
More information about the Twisted-Python
mailing list