[Twisted-Python] Problem with using mktap
![](https://secure.gravatar.com/avatar/90aa9d19ac7df425e4d74b3c23e3ed8d.jpg?s=120&d=mm&r=g)
Hi! I'm implementing a server, who on one sida should have a connection to a unix domain socket and on the other hand listen on a UDP socket. On the unix domain socket this server works as a client. First without mktap. This works: if __name__ == "__main__": port = 6666 sserv = "/tmp/uds" name = "router" f = spocpFactory( ) router = RudsProt( f, name, 1 ) try: reactor.connectUNIX( sserv, f ) reactor.listenUDP( port, router ) reactor.run() except: print "Server missing" What should this look like using mktap ? Tried a simple rewrite: def makeService( config ): port = int(config["port"]) routeServer = config["spocp"] nodename = config["name"] application = service.Application('UDSRouter') f = spocpFactory() reactor.connectUNIX( routeServer, f ) router = RudsProt( f,nodename) udpServer = internet.UDPServer( port, router ) udpServer.setServiceParent(application) return udpServer Didn't work. Well, actually mktap doesn't complain and I get a tap file. But when I run it using twistd spocpFactory doesn't seem to be initialized, ever. -- Roland
![](https://secure.gravatar.com/avatar/d7875f8cfd8ba9262bfff2bf6f6f9b35.jpg?s=120&d=mm&r=g)
On Tue, 2004-11-16 at 19:41 +0100, Roland Hedberg wrote:
def makeService( config ): port = int(config["port"]) routeServer = config["spocp"] nodename = config["name"]
application = service.Application('UDSRouter') <-- DELETE f = spocpFactory() reactor.connectUNIX( routeServer, f ) router = RudsProt( f,nodename) udpServer = internet.UDPServer( port, router ) udpServer.setServiceParent(application) <-- DELETE return udpServer
Get rid of the lines creating an Application instance or using it in any way.
![](https://secure.gravatar.com/avatar/90aa9d19ac7df425e4d74b3c23e3ed8d.jpg?s=120&d=mm&r=g)
2004-11-16 kl. 19.57 skrev Itamar Shtull-Trauring:
On Tue, 2004-11-16 at 19:41 +0100, Roland Hedberg wrote:
def makeService( config ): port = int(config["port"]) routeServer = config["spocp"] nodename = config["name"]
application = service.Application('UDSRouter') <-- DELETE f = spocpFactory() reactor.connectUNIX( routeServer, f ) router = RudsProt( f,nodename) udpServer = internet.UDPServer( port, router ) udpServer.setServiceParent(application) <-- DELETE return udpServer
Get rid of the lines creating an Application instance or using it in any way.
OK, done. So now RudsProt.__init__() is run when I run mktap, but I'm still missing spocpFactory.__init__(). -- Roland
![](https://secure.gravatar.com/avatar/fb44df761a72cca8686ea7faf897344b.jpg?s=120&d=mm&r=g)
Roland Hedberg wrote:
Hi!
I'm implementing a server, who on one sida should have a connection to a unix domain socket and on the other hand listen on a UDP socket.
On the unix domain socket this server works as a client.
First without mktap. This works:
First, is there a good reason to use mktap for your application?
if __name__ == "__main__": port = 6666 sserv = "/tmp/uds" name = "router"
f = spocpFactory( ) router = RudsProt( f, name, 1 )
try: reactor.connectUNIX( sserv, f ) reactor.listenUDP( port, router ) reactor.run() except: print "Server missing"
As a side note this is just bad. Don't use a bare except: unless you absolutely have to, and please document it if you do. -Eric
![](https://secure.gravatar.com/avatar/90aa9d19ac7df425e4d74b3c23e3ed8d.jpg?s=120&d=mm&r=g)
2004-11-16 kl. 20.16 skrev Eric Mangold:
Roland Hedberg wrote:
Hi!
I'm implementing a server, who on one sida should have a connection to a unix domain socket and on the other hand listen on a UDP socket.
On the unix domain socket this server works as a client.
First without mktap. This works:
First, is there a good reason to use mktap for your application?
Not really, except I'd like to know how to use it and its limitations. -- Roland
![](https://secure.gravatar.com/avatar/fb44df761a72cca8686ea7faf897344b.jpg?s=120&d=mm&r=g)
Roland Hedberg wrote:
2004-11-16 kl. 20.16 skrev Eric Mangold:
Roland Hedberg wrote:
Hi!
I'm implementing a server, who on one sida should have a connection to a unix domain socket and on the other hand listen on a UDP socket.
On the unix domain socket this server works as a client.
First without mktap. This works:
First, is there a good reason to use mktap for your application?
Not really, except I'd like to know how to use it and its limitations.
OK. The original tap concept was for applications to store configuration in the tap. Then, such apps could be reconfigured by COIL to do all sorts of wacky things (go way back on the mailing list archives to read about COIL). The implementation of COIL never panned out, and I doubt it ever will. In any case, you certainly don't need tap's to enjoy the benefits of twistd. twistd's -y and related switches should be of interest to you. So, probably, there's not any good reason for you to spend any more time on tap's. -Eric
![](https://secure.gravatar.com/avatar/90aa9d19ac7df425e4d74b3c23e3ed8d.jpg?s=120&d=mm&r=g)
2004-11-16 kl. 21.48 skrev Eric Mangold:
Roland Hedberg wrote:
2004-11-16 kl. 20.16 skrev Eric Mangold:
Roland Hedberg wrote:
Hi!
I'm implementing a server, who on one sida should have a connection to a unix domain socket and on the other hand listen on a UDP socket.
On the unix domain socket this server works as a client.
First without mktap. This works:
First, is there a good reason to use mktap for your application?
Not really, except I'd like to know how to use it and its limitations.
OK.
The original tap concept was for applications to store configuration in the tap. Then, such apps could be reconfigured by COIL to do all sorts of wacky things (go way back on the mailing list archives to read about COIL).
The implementation of COIL never panned out, and I doubt it ever will.
In any case, you certainly don't need tap's to enjoy the benefits of twistd. twistd's -y and related switches should be of interest to you.
So, probably, there's not any good reason for you to spend any more time on tap's.
I hear you. Thanks ! -- Roland
![](https://secure.gravatar.com/avatar/9e03aaf8edbe4b2c0d25e30ab9a69ffb.jpg?s=120&d=mm&r=g)
On Nov 16, 2004, at 12:48 PM, Eric Mangold wrote:
The implementation of COIL never panned out, and I doubt it ever will.
It will. It's pretty much already done in Nevow formless, but someone needs to describe the properties of common servers and finish the shelf so you can drag object references from one place to another. dp
participants (4)
-
Donovan Preston
-
Eric Mangold
-
Itamar Shtull-Trauring
-
Roland Hedberg