Created
September 19, 2019 08:29
-
-
Save sllynn/60fe02d32dcff099f3b2f88108f3e5bb to your computer and use it in GitHub Desktop.
Run multiple notebooks in parallel as ephemeral jobs using python threads
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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