|
7 | 7 | _get_version, |
8 | 8 | _format_auth |
9 | 9 | ) |
10 | | -import sys, subprocess, json, os, asyncio, functools, psycopg2 |
| 10 | +import sys, subprocess, json, os, asyncio, functools, psycopg2, platform |
11 | 11 | from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor |
12 | 12 | from psycopg2.extras import RealDictCursor |
13 | 13 | import pandas as pd |
@@ -539,22 +539,28 @@ async def executeQueriesAsync(self, queries): |
539 | 539 | all the queries are returned as a list of JSON objects if 'dict' output mode is selected, |
540 | 540 | or as a concatenated DataFrame if 'pandas' output mode is selected. |
541 | 541 |
|
542 | | - Note: The order of the results in the returned list or DataFrame may not necessarily |
| 542 | + The order of the results in the returned list or DataFrame may not necessarily |
543 | 543 | correspond to the order of the queries in the input list due to the asynchronous nature |
544 | 544 | of execution. |
545 | 545 |
|
546 | 546 | :param queries: A list of StackQL query strings to be executed concurrently. |
547 | 547 | :type queries: list[str], required |
548 | | -
|
549 | 548 | :return: A list of results corresponding to each query. Each result is a JSON object or a DataFrame. |
550 | 549 | :rtype: list[dict] or pd.DataFrame |
| 550 | + :raises ValueError: If method is used in `server_mode` on an unsupported OS (anything other than Linux). |
| 551 | + :raises ValueError: If an unsupported output mode is selected (anything other than 'dict' or 'pandas'). |
551 | 552 |
|
552 | 553 | Example: |
553 | 554 | >>> queries = [ |
554 | 555 | >>> "SELECT '%s' as region, instanceType, COUNT(*) as num_instances FROM aws.ec2.instances WHERE region = '%s' GROUP BY instanceType" % (region, region) |
555 | 556 | >>> for region in regions ] |
556 | 557 | >>> res = stackql.executeQueriesAsync(queries) |
| 558 | +
|
| 559 | + Note: |
| 560 | + - When operating in `server_mode`, this method is supported only on Linux systems. |
557 | 561 | """ |
| 562 | + if self.server_mode and platform.system() != 'Linux': |
| 563 | + raise ValueError("executeQueriesAsync in sever_mode not supported on MacOS or Linux.") |
558 | 564 | if self.output not in ['dict', 'pandas']: |
559 | 565 | raise ValueError("executeQueriesAsync supports only 'dict' or 'pandas' output modes.") |
560 | 566 | async def main(): |
|
0 commit comments