mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 04:40:22 -07: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:
parent
64fe7402ff
commit
6bad4e57bd
12 changed files with 49 additions and 34 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue