mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Migrate most uses of if type() to if isinstance()
Also convert those checks to use abcs instead of dict and list. Make a sentinel class for strategies to report when they've reache the end
This commit is contained in:
@@ -53,6 +53,9 @@ except ImportError:
|
||||
|
||||
__all__ = ['StrategyBase']
|
||||
|
||||
class StrategySentinel:
|
||||
pass
|
||||
|
||||
# TODO: this should probably be in the plugins/__init__.py, with
|
||||
# a smarter mechanism to set all of the attributes based on
|
||||
# the loaders created there
|
||||
@@ -70,12 +73,12 @@ class SharedPluginLoaderObj:
|
||||
self.module_loader = module_loader
|
||||
|
||||
|
||||
_sentinel = object()
|
||||
_sentinel = StrategySentinel()
|
||||
def results_thread_main(strategy):
|
||||
while True:
|
||||
try:
|
||||
result = strategy._final_q.get()
|
||||
if type(result) == object:
|
||||
if isinstance(result, StrategySentinel):
|
||||
break
|
||||
else:
|
||||
strategy._results_lock.acquire()
|
||||
|
||||
Reference in New Issue
Block a user