Trees | Indices | Help |
---|
|
1 # -*- Mode: Python; test-case-name: flumotion.test.test_common_signals -*- 2 # vi:si:et:sw=4:sts=4:ts=4 3 4 # Flumotion - a streaming media server 5 # Copyright (C) 2004,2005,2006,2007,2008,2009 Fluendo, S.L. 6 # Copyright (C) 2010,2011 Flumotion Services, S.A. 7 # All rights reserved. 8 # 9 # This file may be distributed and/or modified under the terms of 10 # the GNU Lesser General Public License version 2.1 as published by 11 # the Free Software Foundation. 12 # This file is distributed without any warranty; without even the implied 13 # warranty of merchantability or fitness for a particular purpose. 14 # See "LICENSE.LGPL" in the source distribution for more information. 15 # 16 # Headers in this file shall remain intact. 17 18 """synchronous message passing between python objects 19 """ 20 21 from flumotion.common import log 22 23 __version__ = "$Rev$" 24 2527 __signals__ = () 28 29 __signalConnections = None 30 __signalId = 0 31 358337 self.__ensureSignals() 38 39 if signalName not in self.__signals__: 40 raise ValueError('Unknown signal for object of type %r: %s' 41 % (type(self), signalName)) 42 43 sid = self.__signalId 44 self.__signalConnections[sid] = (signalName, proc, args, kwargs) 45 self.__signalId += 1 46 return sid4749 self.__ensureSignals() 50 51 if signalId not in self.__signalConnections: 52 raise ValueError('Unknown signal ID: %s' % (signalId, )) 53 54 del self.__signalConnections[signalId]5557 self.__ensureSignals() 58 59 for signalId, conn in self.__signalConnections.items(): 60 name, proc, args, kwargs = conn 61 if proc == function: 62 break 63 else: 64 raise ValueError( 65 'No signal connected to function: %r' % (function, )) 66 67 del self.__signalConnections[signalId]6870 self.__ensureSignals() 71 if signalName not in self.__signals__: 72 raise ValueError('Emitting unknown signal %s' % signalName) 73 74 connections = self.__signalConnections 75 for name, proc, pargs, pkwargs in connections.values(): 76 if name == signalName: 77 try: 78 proc(self, *(args + pargs), **pkwargs) 79 except Exception, e: 80 log.warning("signalmixin", "Exception calling " 81 "signal handler %r: %s", proc, 82 log.getExceptionMessage(e))
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Tue Aug 13 06:17:20 2013 | http://epydoc.sourceforge.net |