Commit 5da85b40 authored by Denis Bilenko's avatar Denis Bilenko

use second argument to greenlet constructor instead of settings 'parent' attribute

parent cfca6adc
...@@ -65,26 +65,22 @@ def _switch_helper(function, args, kwargs): ...@@ -65,26 +65,22 @@ def _switch_helper(function, args, kwargs):
def spawn(function, *args, **kwargs): def spawn(function, *args, **kwargs):
if kwargs: if kwargs:
g = Greenlet(_switch_helper) g = Greenlet(_switch_helper, get_hub().greenlet)
g.parent = get_hub().greenlet
core.active_event(g.switch, function, args, kwargs) core.active_event(g.switch, function, args, kwargs)
return g return g
else: else:
g = Greenlet(function) g = Greenlet(function, get_hub().greenlet)
g.parent = get_hub().greenlet
core.active_event(g.switch, *args) core.active_event(g.switch, *args)
return g return g
def spawn_later(seconds, function, *args, **kwargs): def spawn_later(seconds, function, *args, **kwargs):
if kwargs: if kwargs:
g = Greenlet(_switch_helper) g = Greenlet(_switch_helper, get_hub().greenlet)
g.parent = get_hub().greenlet
core.timer(seconds, g.switch, function, args, kwargs) core.timer(seconds, g.switch, function, args, kwargs)
return g return g
else: else:
g = Greenlet(function) g = Greenlet(function, get_hub().greenlet)
g.parent = get_hub().greenlet
core.timer(seconds, g.switch, *args) core.timer(seconds, g.switch, *args)
return g return g
......
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