Fokko commented on code in PR #8061: URL: https://github.com/apache/iceberg/pull/8061#discussion_r1265002171
########## python/pyiceberg/utils/concurrent.py: ########## @@ -0,0 +1,67 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# pylint: disable=redefined-outer-name,arguments-renamed,fixme +"""Concurrency concepts that support multi-threading.""" +import threading +from concurrent.futures import Executor, ThreadPoolExecutor Review Comment: @mr-brobot Thanks for raising this. Just to config, as I understand it, AWS Lambda does not support `multiprocessing`, but `concurrent.futures.*` is okay? ########## python/pyiceberg/io/pyarrow.py: ########## @@ -870,15 +870,14 @@ def project_table( id for id in projected_schema.field_ids if not isinstance(projected_schema.find_type(id), (MapType, ListType)) }.union(extract_field_ids(bound_row_filter)) - rows_counter = multiprocessing.Value("i", 0) - - with ThreadPool() as pool: - deletes_per_file = _read_all_delete_files(fs, pool, tasks) + with ManagedThreadPoolExecutor() as executor: + rows_counter = executor.synchronized(0) + deletes_per_file = _read_all_delete_files(fs, executor, tasks) tables = [ table - for table in pool.starmap( - func=_task_to_table, - iterable=[ + for table in executor.map( + lambda args: _task_to_table(*args), Review Comment: Nice -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
