Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid manipulating uninitialized instances on monitoring thread. #493

Closed
wants to merge 2 commits into from

Conversation

davidbau
Copy link
Contributor

This change addresses the race that causes #404 and also mentioned in #323, which is a race that happens with some regularity (but intermittently). The problem is that the monitoring thread is manipulating instances that have been inserted into cls._instances (at the end of __new__) before they have finished their __init__.

This change doesn't change when instances are added to _instances (which might be another change to consider). This change verifies that any retrieved instances have been initialized before manipulating them in the monitoring thread.

The bug is difficult to reproduce, but this fix seems to prevent the bug from occurring for me.

  • I have visited the source website, and in particular
    read the known issues
  • I have searched through the issue tracker for duplicates
  • I have mentioned version numbers, operating system and
    environment, where applicable
  • If applicable, I have mentioned the relevant/related issue(s)

@codecov-io
Copy link

codecov-io commented Dec 27, 2017

Codecov Report

Merging #493 into master will decrease coverage by 0.03%.
The diff coverage is n/a.

@@            Coverage Diff            @@
##           master    #493      +/-   ##
=========================================
- Coverage   99.24%   99.2%   -0.04%     
=========================================
  Files           7       7              
  Lines         658     631      -27     
  Branches      118     120       +2     
=========================================
- Hits          653     626      -27     
+ Misses          3       2       -1     
- Partials        2       3       +1

@casperdcl
Copy link
Member

ah, nice, I like this...

@casperdcl casperdcl self-assigned this Dec 28, 2017
@casperdcl casperdcl added this to the v5.0.0 milestone Dec 28, 2017
@casperdcl casperdcl added p0-bug-critical ☢ Exception rasing to-merge ↰ Imminent labels Dec 28, 2017
Copy link
Member

@lrq3000 lrq3000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good for me! Thanks a lot! 👍

@lrq3000
Copy link
Member

lrq3000 commented Jan 3, 2018

@casperdcl I think the codacy report bugged out, we can probably safely merge!

@MaticConradi
Copy link

Any updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p0-bug-critical ☢ Exception rasing synchronisation ⇶ Multi-thread/processing to-merge ↰ Imminent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants