Author: dmeyer
Date: Tue Sep 26 14:08:03 2006
New Revision: 1908
Modified:
trunk/base/src/notifier/__init__.py
trunk/base/src/notifier/async.py
trunk/base/src/notifier/callback.py
trunk/base/src/notifier/decorators.py
trunk/base/src/notifier/event.py
trunk/base/src/notifier/jobserver.py
trunk/base/src/notifier/nf_wrapper.py
trunk/base/src/notifier/popen.py
trunk/base/src/notifier/sockets.py
trunk/base/src/notifier/thread.py
trunk/base/src/notifier/timer.py
trunk/base/src/notifier/yieldfunc.py
Log:
put kaa.notifier under LGPL 2.1
Modified: trunk/base/src/notifier/__init__.py
==============================================================================
--- trunk/base/src/notifier/__init__.py (original)
+++ trunk/base/src/notifier/__init__.py Tue Sep 26 14:08:03 2006
@@ -5,27 +5,28 @@
# $Id$
#
# -----------------------------------------------------------------------------
-# kaa-notifier - Notifier Wrapper
-# Copyright (C) 2005 Dirk Meyer, et al.
+# kaa.notifier - Mainloop and callbacks
+# Copyright (C) 2005, 2006 Dirk Meyer, Jason Tackaberry, et al.
#
# First Version: Dirk Meyer <[EMAIL PROTECTED]>
# Maintainer: Dirk Meyer <[EMAIL PROTECTED]>
+# Jason Tackaberry <[EMAIL PROTECTED]>
#
-# Please see the file doc/AUTHORS for a complete list of authors.
+# Please see the file AUTHORS for a complete list of authors.
#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
-# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-# Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# This library is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version
+# 2.1 as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA
#
# -----------------------------------------------------------------------------
Modified: trunk/base/src/notifier/async.py
==============================================================================
--- trunk/base/src/notifier/async.py (original)
+++ trunk/base/src/notifier/async.py Tue Sep 26 14:08:03 2006
@@ -1,9 +1,46 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------------
+# async.py - Async callback handling (InProgress)
+# -----------------------------------------------------------------------------
+# $Id$
+#
+# -----------------------------------------------------------------------------
+# kaa.notifier - Mainloop and callbacks
+# Copyright (C) 2006 Dirk Meyer, Jason Tackaberry, et al.
+#
+# First Version: Dirk Meyer <[EMAIL PROTECTED]>
+# Maintainer: Dirk Meyer <[EMAIL PROTECTED]>
+#
+# Please see the file AUTHORS for a complete list of authors.
+#
+# This library is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version
+# 2.1 as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA
+#
+# -----------------------------------------------------------------------------
+
+__all__ = [ 'InProgress' ]
+
+# python imports
import logging
+# kaa.notifier imports
from callback import Signal
+# get logging object
log = logging.getLogger('notifier.async')
+
class InProgress(Signal):
"""
An InProgress class used to return from function calls
@@ -15,7 +52,7 @@
Signal.__init__(self)
self.exception_handler = Signal()
self.is_finished = False
-
+
def finished(self, result):
"""
Modified: trunk/base/src/notifier/callback.py
==============================================================================
--- trunk/base/src/notifier/callback.py (original)
+++ trunk/base/src/notifier/callback.py Tue Sep 26 14:08:03 2006
@@ -5,32 +5,34 @@
# $Id$
#
# -----------------------------------------------------------------------------
-# kaa-notifier - Notifier Wrapper
-# Copyright (C) 2005 Dirk Meyer, et al.
+# kaa.notifier - Mainloop and callbacks
+# Copyright (C) 2005, 2006 Dirk Meyer, Jason Tackaberry, et al.
#
# First Version: Dirk Meyer <[EMAIL PROTECTED]>
# Maintainer: Dirk Meyer <[EMAIL PROTECTED]>
+# Jason Tackaberry <[EMAIL PROTECTED]>
#
-# Please see the file doc/AUTHORS for a complete list of authors.
+# Please see the file AUTHORS for a complete list of authors.
#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
+# This library is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version
+# 2.1 as published by the Free Software Foundation.
#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
-# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-# Public License for more details.
+# This library is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA
#
# -----------------------------------------------------------------------------
__all__ = [ 'Callback', 'WeakCallback', 'Signal' ]
+# Python imports
import _weakref
import types
import sys
@@ -42,9 +44,9 @@
# Variable that is set to True (via atexit callback) when python interpreter
# is in the process of shutting down. If we're interested if the interpreter
-# is shutting down, we don't want to test that this variable is True, but
+# is shutting down, we don't want to test that this variable is True, but
# rather that it is not False, because as it is prefixed with an underscore,
-# the interpreter might already have deleted this variable in which case it
+# the interpreter might already have deleted this variable in which case it
# is None.
_python_shutting_down = False
@@ -143,7 +145,7 @@
cb_kwargs.update(kwargs)
return cb_args, cb_kwargs
-
+
def __call__(self, *args, **kwargs):
"""
@@ -182,7 +184,7 @@
class NotifierCallback(Callback):
-
+
def __init__(self, callback, *args, **kwargs):
super(NotifierCallback, self).__init__(callback, *args, **kwargs)
self._id = None
@@ -192,7 +194,7 @@
"unregistered": Signal()
}
-
+
def active(self):
# callback is active if id is not None and python is not shutting down
# if python is in shutdown, notifier unregister could crash
@@ -220,7 +222,7 @@
try:
ret = super(NotifierCallback, self).__call__(*args, **kwargs)
except:
- # If any of the exception handlers return True, then the
+ # If any of the exception handlers return True, then the
# object is not unregistered from the Notifier. Otherwise
# ret = False and it will unregister.
ret = self.signals["exception"].emit(sys.exc_info()[1])
@@ -269,9 +271,9 @@
if _python_shutting_down != False:
# Shutdown
return False
-
+
save_args, save_kwargs = self._args, self._kwargs
-
+
# Remove weakrefs from user data before invoking the callback.
self._args = unweakref_data(self._args)
self._kwargs = unweakref_data(self._kwargs)
@@ -279,7 +281,7 @@
result = super(WeakCallback, self).__call__(*args, **kwargs)
self._args, self._kwargs = save_args, save_kwargs
-
+
return result
@@ -344,7 +346,7 @@
return False
- def _connect(self, callback, args = (), kwargs = {}, once = False,
+ def _connect(self, callback, args = (), kwargs = {}, once = False,
weak = False, pos = -1):
assert(callable(callback))
@@ -486,5 +488,5 @@
def _shutdown_weakref_destroyed():
global _python_shutting_down
_python_shutting_down = True
-
+
atexit.register(_shutdown_weakref_destroyed)
Modified: trunk/base/src/notifier/decorators.py
==============================================================================
--- trunk/base/src/notifier/decorators.py (original)
+++ trunk/base/src/notifier/decorators.py Tue Sep 26 14:08:03 2006
@@ -5,27 +5,27 @@
# $Id$
#
# -----------------------------------------------------------------------------
-# kaa-notifier - Notifier Wrapper
-# Copyright (C) 2005 Dirk Meyer, et al.
+# kaa.notifier - Mainloop and callbacks
+# Copyright (C) 2006 Dirk Meyer, Jason Tackaberry, et al.
#
# First Version: Dirk Meyer <[EMAIL PROTECTED]>
# Maintainer: Dirk Meyer <[EMAIL PROTECTED]>
#
# Please see the file AUTHORS for a complete list of authors.
#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
-# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-# Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# This library is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version
+# 2.1 as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA
#
# -----------------------------------------------------------------------------
Modified: trunk/base/src/notifier/event.py
==============================================================================
--- trunk/base/src/notifier/event.py (original)
+++ trunk/base/src/notifier/event.py Tue Sep 26 14:08:03 2006
@@ -5,27 +5,27 @@
# $Id$
#
# -----------------------------------------------------------------------------
-# kaa-notifier - Notifier Wrapper
-# Copyright (C) 2005 Dirk Meyer, et al.
+# kaa.notifier - Mainloop and callbacks
+# Copyright (C) 2005, 2006 Dirk Meyer, Jason Tackaberry, et al.
#
# First Version: Dirk Meyer <[EMAIL PROTECTED]>
# Maintainer: Dirk Meyer <[EMAIL PROTECTED]>
#
-# Please see the file doc/AUTHORS for a complete list of authors.
+# Please see the file AUTHORS for a complete list of authors.
#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
-# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-# Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# This library is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version
+# 2.1 as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA
#
# -----------------------------------------------------------------------------
@@ -63,7 +63,7 @@
if args:
self._set_args(args)
-
+
def _set_args(self, args):
"""
Set arguments of the event.
@@ -89,7 +89,7 @@
else:
return manager.post(event)
-
+
def __str__(self):
"""
Return the event as string
@@ -128,7 +128,7 @@
"""
return self in manager.handler
-
+
def unregister(self):
"""
Unregister callback.
@@ -171,7 +171,7 @@
self.queue.append(event)
if not self.timer.active():
self.timer.start(0)
-
+
def handle(self):
"""
@@ -185,7 +185,7 @@
self.locked = True
event = self.queue[0]
self.queue = self.queue[1:]
-
+
try:
for handler in copy.copy(self.handler):
handler(event)
Modified: trunk/base/src/notifier/jobserver.py
==============================================================================
--- trunk/base/src/notifier/jobserver.py (original)
+++ trunk/base/src/notifier/jobserver.py Tue Sep 26 14:08:03 2006
@@ -5,27 +5,27 @@
# $Id$
#
# -----------------------------------------------------------------------------
-# kaa-notifier - Notifier Wrapper
-# Copyright (C) 2005 Dirk Meyer, et al.
+# kaa.notifier - Mainloop and callbacks
+# Copyright (C) 2005, 2006 Dirk Meyer, Jason Tackaberry, et al.
#
# First Version: Dirk Meyer <[EMAIL PROTECTED]>
# Maintainer: Dirk Meyer <[EMAIL PROTECTED]>
#
-# Please see the file doc/AUTHORS for a complete list of authors.
+# Please see the file AUTHORS for a complete list of authors.
#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
-# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-# Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# This library is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version
+# 2.1 as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA
#
# -----------------------------------------------------------------------------
Modified: trunk/base/src/notifier/nf_wrapper.py
==============================================================================
--- trunk/base/src/notifier/nf_wrapper.py (original)
+++ trunk/base/src/notifier/nf_wrapper.py Tue Sep 26 14:08:03 2006
@@ -1,3 +1,35 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------------
+# nf_wrapper.py - Wrapper to notifier calls to delay the real import
+# -----------------------------------------------------------------------------
+# $Id$
+#
+# -----------------------------------------------------------------------------
+# kaa.notifier - Mainloop and callbacks
+# Copyright (C) 2006 Dirk Meyer, Jason Tackaberry, et al.
+#
+# First Version: Dirk Meyer <[EMAIL PROTECTED]>
+# Maintainer: Dirk Meyer <[EMAIL PROTECTED]>
+#
+# Please see the file AUTHORS for a complete list of authors.
+#
+# This library is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version
+# 2.1 as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA
+#
+# -----------------------------------------------------------------------------
+
+# Python imports
import logging
import sys
@@ -44,13 +76,13 @@
if not isinstance(loop, _Wrapper):
raise RuntimeError('notifier loop already running')
-
+
try:
import notifier
except ImportError:
# use our own copy of pynotifier
import pynotifier as notifier
-
+
if notifier.loop:
# pyNotifier should be used and already active
log = logging.getLogger('notifier')
@@ -84,7 +116,7 @@
nf_conditions = [ notifier.IO_READ, notifier.IO_WRITE ]
socket_remove = _socket_remove
socket_add = _socket_add
-
+
dispatcher_add = notifier.dispatcher_add
dispatcher_remove = notifier.dispatcher_remove
Modified: trunk/base/src/notifier/popen.py
==============================================================================
--- trunk/base/src/notifier/popen.py (original)
+++ trunk/base/src/notifier/popen.py Tue Sep 26 14:08:03 2006
@@ -19,28 +19,28 @@
# to stop all running processes.
#
# -----------------------------------------------------------------------------
-# kaa-notifier - Notifier Wrapper
-# Copyright (C) 2005 Dirk Meyer, et al.
+# kaa.notifier - Mainloop and callbacks
+# Copyright (C) 2005, 2006 Dirk Meyer, Jason Tackaberry, et al.
#
# First Version: Dirk Meyer <[EMAIL PROTECTED]>
# Maintainer: Dirk Meyer <[EMAIL PROTECTED]>
#
# Based on code by Krister Lagerstrom and Andreas B�sching
-# Please see the file doc/AUTHORS for a complete list of authors.
+# Please see the file AUTHORS for a complete list of authors.
#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
+# This library is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version
+# 2.1 as published by the Free Software Foundation.
#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
-# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-# Public License for more details.
+# This library is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA
#
# -----------------------------------------------------------------------------
@@ -124,10 +124,10 @@
else:
curarg += c
last = c
-
+
if curarg:
cmdlist.append(curarg)
-
+
return cmdlist
@@ -208,7 +208,7 @@
return
if not is_mainthread():
return MainThreadCallback(self.stop, cmd)()
-
+
self.stopping = True
cmd = cmd or self._stop_cmd
@@ -453,7 +453,7 @@
# call stopped callback
callback = self.__processes[p]
# Delete the callback from the processes list before calling
- # it, since it's possible the callback could call append
+ # it, since it's possible the callback could call append
# again.
del self.__processes[p]
callback(status)
@@ -477,7 +477,7 @@
p.stop()
self.status = 'stopping'
-
+
def killall( self ):
# prevent recursion
if not self.status in ('running', 'stopping'):
@@ -485,7 +485,7 @@
# make sure every child is stopped
self.stopall()
self.status = 'stopped'
-
+
# now wait until all childs are dead
while self.__processes:
self.check()
Modified: trunk/base/src/notifier/sockets.py
==============================================================================
--- trunk/base/src/notifier/sockets.py (original)
+++ trunk/base/src/notifier/sockets.py Tue Sep 26 14:08:03 2006
@@ -5,31 +5,33 @@
# $Id$
#
# -----------------------------------------------------------------------------
-# kaa-notifier - Notifier Wrapper
-# Copyright (C) 2005 Dirk Meyer, et al.
+# kaa.notifier - Mainloop and callbacks
+# Copyright (C) 2005, 2006 Dirk Meyer, Jason Tackaberry, et al.
#
# First Version: Dirk Meyer <[EMAIL PROTECTED]>
# Maintainer: Dirk Meyer <[EMAIL PROTECTED]>
+# Jason Tackaberry <[EMAIL PROTECTED]>
#
-# Please see the file doc/AUTHORS for a complete list of authors.
+# Please see the file AUTHORS for a complete list of authors.
#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
+# This library is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version
+# 2.1 as published by the Free Software Foundation.
#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
-# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-# Public License for more details.
+# This library is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA
#
# -----------------------------------------------------------------------------
-__all__ = [ 'SocketDispatcher', 'WeakSocketDispatcher', 'Socket', 'IO_READ',
'IO_WRITE' ]
+__all__ = [ 'SocketDispatcher', 'WeakSocketDispatcher', 'Socket',
+ 'IO_READ', 'IO_WRITE' ]
import socket
import logging
@@ -134,7 +136,8 @@
# Change port to (None, port)
bind_info = ("", bind_info)
- if not isinstance(bind_info, (tuple, list)) or not
isinstance(bind_info[0], (tuple, list)):
+ if not isinstance(bind_info, (tuple, list)) or \
+ not isinstance(bind_info[0], (tuple, list)):
bind_info = (bind_info, )
@@ -157,7 +160,7 @@
"""
Connects to the host specified in addr. If addr is a string in the
form host:port, or a tuple the form (host, port), a TCP socket is
- established. Otherwise a Unix socket is established and addr is
+ established. Otherwise a Unix socket is established and addr is
treated as a filename.
If async is not None, it is a callback that will be invoked when the
@@ -249,7 +252,7 @@
if not data:
return self.close(False)
-
+
self.signals["read"].emit(data)
Modified: trunk/base/src/notifier/thread.py
==============================================================================
--- trunk/base/src/notifier/thread.py (original)
+++ trunk/base/src/notifier/thread.py Tue Sep 26 14:08:03 2006
@@ -21,31 +21,33 @@
# wrap a function in a thread.
#
# -----------------------------------------------------------------------------
-# kaa-notifier - Notifier Wrapper
-# Copyright (C) 2005 Dirk Meyer, et al.
+# kaa.notifier - Mainloop and callbacks
+# Copyright (C) 2005, 2006 Dirk Meyer, Jason Tackaberry, et al.
#
# First Version: Dirk Meyer <[EMAIL PROTECTED]>
# Maintainer: Dirk Meyer <[EMAIL PROTECTED]>
+# Jason Tackaberry <[EMAIL PROTECTED]>
#
-# Please see the file doc/AUTHORS for a complete list of authors.
+# Please see the file AUTHORS for a complete list of authors.
#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
-# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-# Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# This library is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version
+# 2.1 as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA
#
# -----------------------------------------------------------------------------
-__all__ = [ 'MainThreadCallback', 'Thread', 'is_mainthread', 'wakeup',
'set_current_as_mainthread' ]
+__all__ = [ 'MainThreadCallback', 'Thread', 'is_mainthread', 'wakeup',
+ 'set_current_as_mainthread' ]
# python imports
import sys
@@ -87,11 +89,11 @@
def _set_exception(self, e):
self._sync_exception = e
self._wakeup()
-
+
def _wakeup(self):
self.lock.acquire(False)
self.lock.release()
-
+
def __call__(self, *args, **kwargs):
if threading.currentThread() == _thread_notifier_mainthread:
return super(MainThreadCallback, self).__call__(*args, **kwargs)
@@ -128,9 +130,9 @@
class Thread(threading.Thread):
"""
- Notifier aware wrapper for threads. When a thread is started, it is
impossible to
- fork the current process into a second one without exec both using the
notifier
- main loop because of the shared _thread_notifier_pipe.
+ Notifier aware wrapper for threads. When a thread is started, it is
+ impossible to fork the current process into a second one without exec both
+ using the notifier main loop because of the shared _thread_notifier_pipe.
"""
def __init__(self, function, *args, **kargs):
threading.Thread.__init__(self)
@@ -142,7 +144,7 @@
"completed": Signal(),
"exception": Signal()
}
-
+
def _emit_and_join(self, signal, arg):
"""
Run callback signals and join dead thread.
@@ -180,10 +182,11 @@
_thread_notifier_lock = threading.Lock()
_thread_notifier_queue = []
-# For MainThread* callbacks. The pipe will be created when it is used the
first time.
-# This solves a nasty bug when you fork() into a second notifier based process
without
-# exec. If you have this pipe, communication will go wrong.
+# For MainThread* callbacks. The pipe will be created when it is used the first
+# time. This solves a nasty bug when you fork() into a second notifier based
+# process without exec. If you have this pipe, communication will go wrong.
_thread_notifier_pipe = None
+
def _create_thread_notifier_pipe():
global _thread_notifier_pipe
log.info('create thread notifier pipe')
@@ -202,13 +205,13 @@
_create_thread_notifier_pipe()
if len(_thread_notifier_queue) == 0:
os.write(_thread_notifier_pipe[1], "1")
-
-
+
+
def set_current_as_mainthread():
global _thread_notifier_mainthread
_thread_notifier_mainthread = threading.currentThread()
-
-
+
+
def _thread_notifier_run_queue(fd):
global _thread_notifier_queue
try:
Modified: trunk/base/src/notifier/timer.py
==============================================================================
--- trunk/base/src/notifier/timer.py (original)
+++ trunk/base/src/notifier/timer.py Tue Sep 26 14:08:03 2006
@@ -5,27 +5,28 @@
# $Id$
#
# -----------------------------------------------------------------------------
-# kaa-notifier - Notifier Wrapper
-# Copyright (C) 2005 Dirk Meyer, et al.
+# kaa.notifier - Mainloop and callbacks
+# Copyright (C) 2005, 2006 Dirk Meyer, Jason Tackaberry, et al.
#
# First Version: Dirk Meyer <[EMAIL PROTECTED]>
# Maintainer: Dirk Meyer <[EMAIL PROTECTED]>
+# Jason Tackaberry <[EMAIL PROTECTED]>
#
-# Please see the file doc/AUTHORS for a complete list of authors.
+# Please see the file AUTHORS for a complete list of authors.
#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
-# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-# Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# This library is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version
+# 2.1 as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA
#
# -----------------------------------------------------------------------------
Modified: trunk/base/src/notifier/yieldfunc.py
==============================================================================
--- trunk/base/src/notifier/yieldfunc.py (original)
+++ trunk/base/src/notifier/yieldfunc.py Tue Sep 26 14:08:03 2006
@@ -32,31 +32,32 @@
# The default value is 0, the first iteration is always called without a timer.
#
# -----------------------------------------------------------------------------
-# kaa-notifier - Notifier Wrapper
-# Copyright (C) 2006 Dirk Meyer, et al.
+# kaa.notifier - Mainloop and callbacks
+# Copyright (C) 2006 Dirk Meyer, Jason Tackaberry, et al.
#
# First Version: Dirk Meyer <[EMAIL PROTECTED]>
# Maintainer: Dirk Meyer <[EMAIL PROTECTED]>
#
# Please see the file AUTHORS for a complete list of authors.
#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
-# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-# Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# This library is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version
+# 2.1 as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA
#
# -----------------------------------------------------------------------------
-__all__ = [ 'YieldContinue', 'YieldCallback', 'yield_execution',
'YieldFunction' ]
+__all__ = [ 'YieldContinue', 'YieldCallback', 'yield_execution',
+ 'YieldFunction' ]
import sys
import logging
@@ -183,7 +184,7 @@
return True
return InProgress.__call__(self, *args, **kwargs)
-
+
def _continue(self, *args, **kwargs):
"""
Restart timer.
@@ -191,7 +192,7 @@
if self._timer:
self._timer.start(self._interval)
-
+
def _step(self):
"""
Call next step of the yield function.
@@ -225,4 +226,3 @@
self._timer.stop()
self._timer = None
self._yield__function = None
-
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog