Skip to content

Commit

Permalink
GenericRepository: fix unpickling of objects
Browse files Browse the repository at this point in the history
This allows them to be passed across process boundaries when using
`concurrent.futures.ProcessPoolExecutor`.  Without this, a
`RecursionError` occurs.

The issue stems from `GenericRepository.__getattr__` calling
`getattr(self.path, ...)`.  `GenericRepository.path` is a property, so
it is found, but it then calls `self._artifactory.joinpath(...)` and
`self._artifactory` is not yet present on the partially-restored
`GenericRepository`, resulting in a call to
`GenericRepository.__getattr__`, etc.

This fix ensures that `self._artifactory` will be restored to the object
early enough in unpickling to avoid the issue.
  • Loading branch information
OddBloke committed Sep 25, 2024
1 parent c0d788c commit 484ef95
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dohq_artifactory/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,12 @@ def __rtruediv__(self, key):
__div__ = __truediv__
__rdiv__ = __rtruediv__

def __setstate__(self, state):
self.__dict__ = state

def __getstate__(self):
return self.__dict__


class Repository(GenericRepository):
# List package_type from wiki:
Expand Down

0 comments on commit 484ef95

Please sign in to comment.