From f5447ef3451d918ab1df3052d03c87ace6fe6812 Mon Sep 17 00:00:00 2001 From: Denis Bilenko Date: Thu, 11 Jun 2009 17:12:52 +0700 Subject: [PATCH] add greenlib module for backward compatibility; mark it as deprecated --- eventlet/greenlib.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 eventlet/greenlib.py diff --git a/eventlet/greenlib.py b/eventlet/greenlib.py new file mode 100644 index 0000000..1c3f995 --- /dev/null +++ b/eventlet/greenlib.py @@ -0,0 +1,20 @@ +from eventlet.api import Greenlet + +class SwitchingToDeadGreenlet(Exception): + pass + +def switch(other=None, value=None, exc=None): + self = Greenlet.getcurrent() + if other is None: + other = self.parent + if other is None: + other = self + if not (other or hasattr(other, 'run')): + raise SwitchingToDeadGreenlet("Switching to dead greenlet %r %r %r" % (other, value, exc)) + if exc: + return other.throw(exc) + else: + return other.switch(value) + +import warnings +warnings.warn("greenlib is deprecated; use greenlet methods directly", DeprecationWarning, stacklevel=2)