Author: rshortt Date: Mon Jan 7 20:02:51 2008 New Revision: 2957 Log: Check for int or socket (well, something with fileno()), other general improvements.
Modified: trunk/base/src/notifier/pynotifier/nf_twisted.py Modified: trunk/base/src/notifier/pynotifier/nf_twisted.py ============================================================================== --- trunk/base/src/notifier/pynotifier/nf_twisted.py (original) +++ trunk/base/src/notifier/pynotifier/nf_twisted.py Mon Jan 7 20:02:51 2008 @@ -40,6 +40,9 @@ http://twistedmatrix.com/projects/core/documentation/howto/index.html """ +# Python imports +from types import IntType + # Twisted uses zope.interface from zope.interface import implements @@ -50,6 +53,7 @@ # internal packages import dispatch +import log IO_READ = 1 IO_WRITE = 2 @@ -83,16 +87,17 @@ socket_remove(self.socket, IO_READ) def fileno(self): - # FIXME: check is socket is a socket or int - return self.socket + if type(self.socket) is IntType: + return self.socket + elif hasattr(self.socket, 'fileno'): + return self.socket.fileno() def logPrefix(self): - # FIXME: debug and improve if needed - return "doRead: " + return "notifier" def connectionLost(self, reason): - # FIXME: debug and improve if needed - print "connectionLost" + # Should we do more? + log.error("connection lost on socket fd=%s" % self.fileno()) class SocketWriteCB: @@ -115,16 +120,17 @@ socket_remove(self.socket, IO_WRITE) def fileno(self): - # FIXME: check is socket is a socket or int - return self.socket + if type(self.socket) is IntType: + return self.socket + elif hasattr(self.socket, 'fileno'): + return self.socket.fileno() def logPrefix(self): - # FIXME: debug and improve if needed - return "doWrite: " + return "notifier" def connectionLost(self, reason): - # FIXME: debug and improve if needed - print "connectionLost" + # Should we do more? + log.error("connection lost on socket fd=%s" % self.fileno()) def socket_add(id, method, condition = IO_READ): ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace _______________________________________________ Freevo-cvslog mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/freevo-cvslog
