Skip to content

Commit 1962e1d

Browse files
authored
Merge pull request #91 from jeremycarroll/master
Wrap leave_module method in thread-safe manner
2 parents d193665 + cdc0b4d commit 1962e1d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pylint_django/augmentations/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,4 +772,11 @@ def apply_augmentations(linter):
772772
suppress_message(linter, _leave_class(MisdesignChecker), 'too-few-public-methods', is_model_mpttmeta_subclass)
773773

774774
# ForeignKey and OneToOneField
775-
VariablesChecker.leave_module = wrap(VariablesChecker.leave_module, ignore_import_warnings_for_related_fields)
775+
# Must update this in a thread safe way to support the parallel option on pylint (-j)
776+
current_leave_module = VariablesChecker.leave_module
777+
if current_leave_module.__name__ == 'leave_module':
778+
# current_leave_module is not wrapped
779+
# Two threads may hit the next assignment concurrently, but the result is the same
780+
VariablesChecker.leave_module = wrap(current_leave_module, ignore_import_warnings_for_related_fields)
781+
# VariablesChecker.leave_module is now wrapped
782+
# else VariablesChecker.leave_module is already wrapped

0 commit comments

Comments
 (0)