add greenlib module for backward compatibility; mark it as deprecated
This commit is contained in:
20
eventlet/greenlib.py
Normal file
20
eventlet/greenlib.py
Normal file
@@ -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)
|
Reference in New Issue
Block a user