I think you want to put your code in a function and then call it asynchronously using asyncio. You'll have to install asyncio using:
pip install asyncio
I just put your code in an async method and call that method from main() using asyncio. Async code is just kinda different to work with.
Here's an example that uses a function and is called from main(). It downloads data for two tables.
Jason
import os
from dap.api import DAPClient
from dap.dap_types import Format, SnapshotQuery
import asyncio
async def download_table_data(namespace, table):
query = SnapshotQuery(format=Format.JSONL, filter=None)
output_directory = os.getcwd()
await session.download_table_data(namespace, table, query, output_directory)
def main():
loop = asyncio.get_event_loop()
loop.run_until_complete(download_table_data("canvas", "accounts"))
loop.run_until_complete(download_table_data("canvas_logs", "web_logs"))
if __name__ == '__main__':
main()