-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2554 from fishtown-analytics/fix/parallel-rpc-met…
…hod-stomping Fix parallel rpc methods (2484)
- Loading branch information
Showing
5 changed files
with
47 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from concurrent.futures import ThreadPoolExecutor, as_completed | ||
|
||
from .util import ( | ||
get_querier, | ||
ProjectDefinition, | ||
) | ||
|
||
|
||
def _compile_poll_for_result(querier, id: int): | ||
sql = f'select {id} as id' | ||
resp = querier.compile_sql( | ||
request_id=id, sql=sql, name=f'query_{id}' | ||
) | ||
compile_sql_result = querier.async_wait_for_result(resp) | ||
assert compile_sql_result['results'][0]['compiled_sql'] == sql | ||
|
||
|
||
def test_rpc_compile_sql_concurrency( | ||
project_root, profiles_root, postgres_profile, unique_schema | ||
): | ||
project = ProjectDefinition( | ||
models={'my_model.sql': 'select 1 as id'} | ||
) | ||
querier_ctx = get_querier( | ||
project_def=project, | ||
project_dir=project_root, | ||
profiles_dir=profiles_root, | ||
schema=unique_schema, | ||
test_kwargs={}, | ||
) | ||
|
||
with querier_ctx as querier: | ||
values = {} | ||
with ThreadPoolExecutor(max_workers=10) as tpe: | ||
for id in range(20): | ||
fut = tpe.submit(_compile_poll_for_result, querier, id) | ||
values[fut] = id | ||
for fut in as_completed(values): | ||
fut.result() |