Uploaded image for project: 'Nuxeo Drive '
  1. Nuxeo Drive
  2. NXDRIVE-2083

Use dict.copy() for thread safety, better atomicity speed and memory efficiency

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: NoFixVersionApplicable
    • Fix Version/s: 4.4.5
    • Component/s: Framework
    • Release Notes Summary:
      Thread-Safety
    • Release Notes Description:
      Hide

      We adapted a bunch of code to be really thread-safe, espacially when iterating over a dict. It also improve atomicity speed and the code is more memory efficient now.

      For instance, that code is not completely thread-safe:

      for item in list(self.my_queue.values()):
          # ...
      

      And such code is not immunte to "dictionary changed size during iteration" errors.

      Here is the new code:

      for item in self.my_queue.copy().values():
          # ...
      

      it applies to all operations on dict objects: dict.items(), dict.keys() and dict.values().

      Show
      We adapted a bunch of code to be really thread-safe, espacially when iterating over a dict . It also improve atomicity speed and the code is more memory efficient now. For instance, that code is not completely thread-safe: for item in list ( self .my_queue.values()): # ... And such code is not immunte to "dictionary changed size during iteration" errors. Here is the new code: for item in self .my_queue.copy().values(): # ... it applies to all operations on dict objects: dict.items() , dict.keys() and dict.values() .
    • Epic Link:
    • Tags:
    • Story Points:
      1

      Description

      According to bpo-13487 and that associated commit, it seems that list(dict.items()), list(dict.keys()) and list(dict.values()) are apparently not immune to "dictionary changed size during iteration" errors.

      We have a bunch of code like the "fragile" one and we should do a one-time clean-up.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 45 minutes
                  45m

                    PagerDuty

                    Error rendering 'com.pagerduty.jira-server-plugin:PagerDuty'. Please contact your Jira administrators.