Skip to content

Instantly share code, notes, and snippets.

@sllynn
Created September 19, 2019 08:29
Show Gist options
  • Save sllynn/60fe02d32dcff099f3b2f88108f3e5bb to your computer and use it in GitHub Desktop.
Save sllynn/60fe02d32dcff099f3b2f88108f3e5bb to your computer and use it in GitHub Desktop.
Run multiple notebooks in parallel as ephemeral jobs using python threads
from threading import Thread
def producer_method():
dbutils.notebook.run(
path="./kinesis-producer",
timeout_seconds=600,
arguments={
"kinesisRegion": KINESIS_REGION,
"inputStream": INPUT_STREAM,
"newsgroupDataLocation": NEWSGROUP_DATA_PATH
}
)
def consumer_method():
dbutils.notebook.run(
path="./kinesis-consumer",
timeout_seconds=600,
arguments={
"kinesisRegion": KINESIS_REGION,
"relayStream": RELAY_STREAM
}
)
producer_thread = Thread(target=producer_method)
consumer_thread = Thread(target=consumer_method)
producer_thread.start()
consumer_thread.start()
producer_thread.join()
consumer_thread.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment