Commit 4e7b1453 authored by Denis Bilenko's avatar Denis Bilenko

gevent.Greenlet: allow spawn with no parameters

parent b13f582f
...@@ -135,6 +135,7 @@ class FailureGreenletLink(GreenletLink): ...@@ -135,6 +135,7 @@ class FailureGreenletLink(GreenletLink):
if not source.successful(): if not source.successful():
return GreenletLink.__call__(self, source) return GreenletLink.__call__(self, source)
class Greenlet(greenlet): class Greenlet(greenlet):
# QQQ rename to Microthread # QQQ rename to Microthread
"""A greenlet subclass that adds a few features. """A greenlet subclass that adds a few features.
...@@ -201,7 +202,7 @@ class Greenlet(greenlet): ...@@ -201,7 +202,7 @@ class Greenlet(greenlet):
return core.timer(seconds, self.switch, *args) return core.timer(seconds, self.switch, *args)
@classmethod @classmethod
def spawn(cls, function, *args, **kwargs): def spawn(cls, function=None, *args, **kwargs):
if kwargs: if kwargs:
g = cls(_switch_helper) g = cls(_switch_helper)
g.start(function, args, kwargs) g.start(function, args, kwargs)
...@@ -212,7 +213,7 @@ class Greenlet(greenlet): ...@@ -212,7 +213,7 @@ class Greenlet(greenlet):
return g return g
@classmethod @classmethod
def spawn_later(cls, seconds, function, *args, **kwargs): def spawn_later(cls, seconds, function=None, *args, **kwargs):
if kwargs: if kwargs:
g = cls(_switch_helper) g = cls(_switch_helper)
timer = g.start_later(seconds, function, args, kwargs) timer = g.start_later(seconds, function, args, kwargs)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment