Skip to content

Instantly share code, notes, and snippets.

@zamn

zamn/batch.py Secret

Created March 3, 2020 05:13
Show Gist options
  • Save zamn/84b461aaa702722df33042a82cb97367 to your computer and use it in GitHub Desktop.
Save zamn/84b461aaa702722df33042a82cb97367 to your computer and use it in GitHub Desktop.
import os
env = Environment(ENV=os.environ)
def action_func(target = None, source = None, env = None):
print('my targets', target)
return 0
my_batched_action = env.Action(action_func, batch_key=True)
env.Command(target='hello', source='world', action=my_batched_action)
env.Command(target='goodbye', source='world', action=my_batched_action)
# The above output:
# action_func(["hello", "goodbye"], ["world", "world"])
# ('my targets', [<SCons.Node.FS.File object at 0x55e4f8737250>, <SCons.Node.FS.File object at 0x55e4f87379f0>])
my_second_batched_action = env.Action(action_func, batch_key=True)
env.Command(target='end', source='world', action=[my_batched_action, my_second_batched_action])
env.Command(target='sad', source='world', action=[my_batched_action, my_second_batched_action])
# action_func(["end"], ["world"])
# ('my targets', [<SCons.Node.FS.File object at 0x55e4f8738cb0>])
# action_func(["end"], ["world"])
# ('my targets', [<SCons.Node.FS.File object at 0x55e4f8738cb0>])
# action_func(["sad"], ["world"])
# ('my targets', [<SCons.Node.FS.File object at 0x55e4f8739250>])
# action_func(["sad"], ["world"])
# ('my targets', [<SCons.Node.FS.File object at 0x55e4f8739250>])
# I would expect it to match the first example.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment