60afc0eec4
When we run the tripleo-container-image-prepare script, it performs better under python2 when the process leverages a ProcessPoolExecutor. Rather than using threading, we should be using processes to handle the image upload processing. Currently when we're processing the images, we end up being single threaded due to the GIL when processing the data. By switching to the ProcessPoolExecutor, we eliminate the locking that is occuring during the data processing as it'll be handled in each process. Unfortunately, we cannot leverage the ProcessPoolExecutor when the same code is run under Mistral. In order to make the code work for both methods, we need to make the execution type dynamic. This change creates two types of lock objects that are used to determine what type of executor to ultimately use when processing the images for uploading. Additionally this change limits the number of concurrent image upload processes to 4 if using the ProcessPoolExecutor and caps the number of threads at a max of 8 based on (cpu count / 2) Change-Id: I60507eba9884a0660fe269da5ad27b0e57a70ca8 Related-Bug: #1844446
22 lines
727 B
Python
22 lines
727 B
Python
# Copyright 2019 Red Hat, Inc.
|
|
#
|
|
# Licensed 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.
|
|
|
|
|
|
class BaseLock(object):
|
|
def get_lock(self):
|
|
return self._lock
|
|
|
|
def objects(self):
|
|
return self._objects
|