Jump to content

How to asynchronously run scripts ?


Recommended Posts

Hi everyone.

 

Context: I am writing a workflow based on a Script Filter, but for external reasons the results come pretty slowly and one by one. As far as I'm aware it's impossible to stream results directly with the script filter object. So, what I wanted to do, is to fetch the results asynchronously, write them in a file, and have the Script Filter just look at the file. Using the rerun option to 'refresh' results regularly I could make it work.

 

So my question is: How to asynchronously run scripts in a workflow? Just launching the script but not waiting for it to end before continuing the workflow.

It could be a python or bash script, it could be called by a 'Run Script' object or directly in the script filter; it doesn't really matter.

I've tried the two following things that I thought would work, but Alfred still waits for the other script to finish before continuing.

 

import subprocess
subprocess.Popen(["./other-script.sh"])

 

#!/bin/bash

./other-script.sh & echo -n "continue"

 

Thanks a lot,

 

Leo

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...