Jump to content

rerun=False, rerun=None, rerun=0 ... ?

Recommended Posts



  • Alfred 4.6.3 [1285]
  • macOS 12.2.1


I'm working on a Python workflow and am making use of the rerun parameter. So far so good. 


BUT, sometimes depending on the workflow inputs or outputs, I do NOT want it to rerun.


I've tried the following variations, but using None or False results in the workflow never displaying any output (even though the JSON looks correct in the debug console)



json.dump(dict(rerun=False, items=items, sys.stdout, indent=2)



json.dump(dict(rerun=None, items=items, sys.stdout, indent=2)



json.dump(dict(rerun=0, items=items, sys.stdout, indent=2)


The only flavor that "works" is rerun=0, although that results in an orange WARNING from Alfred that WARNING: Foo[Script Filter] Script rerun of 0.00 is out of range (0.1s to 5s), rerun will be ignored —so that seems like a bad solution.


I realize I could make some extra code paths in my script to account for these edge cases when I don't want the rerun to happen, but I'd love it if I could just keep it DRY and use the same json.dump() for everything. Is this a bug or a feature request?


Edited by luckman212
Link to comment

For now I ended up using a small helper function, this allows passing rt=None,False,0 etc... without causing an issue


def json_out(d, rt=None):
  d_out = dict(items=d)
  if isinstance(rt, (float,int)):
    if 0.1 < rt <= 5.0:
      d_out["rerun"] = rt
      print(f'rerun ({rt}) is OUT OF RANGE 0.1-5.0', file=sys.stderr)
  json.dump(d_out, sys.stdout, indent=2)


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...