@contextmanager
def fake_spawn():
 greenlets = []
 def _inner_fake_spawn(func, *a, **kw):
  gt = greenthread.spawn(func, *a, **kw)
  greenlets.append(gt)
  return gt
 object_server.spawn = _inner_fake_spawn
 with mock.patch('swift.obj.server.spawn', _inner_fake_spawn):
  try:
   (yield)
  finally:
   for gt in greenlets:
    gt.wait()

@ contextmanager def fake_spawn ( ) : greenlets = [ ] def _inner_fake_spawn ( func , * a , ** kw ) : gt = greenthread . spawn ( func , * a , ** kw ) greenlets . append ( gt ) return gt object_server . spawn = _inner_fake_spawn with mock . patch ( 'swift.obj.server.spawn' , _inner_fake_spawn ) : try : ( yield ) finally : for gt in greenlets : gt . wait ( )
spawn and capture the result so we can later wait on it .