diff options
| author | Barry Warsaw | 2011-04-08 22:13:16 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2011-04-08 22:13:16 -0400 |
| commit | 2102f99312d81e1869060f6c7dff286663540c3b (patch) | |
| tree | 2c9cd93c833ed66801c0713ed78dbbf16d812260 /src/mailman/utilities/uid.py | |
| parent | 5de5904af6dd97339a70630002d64c901b008c98 (diff) | |
| download | mailman-2102f99312d81e1869060f6c7dff286663540c3b.tar.gz mailman-2102f99312d81e1869060f6c7dff286663540c3b.tar.zst mailman-2102f99312d81e1869060f6c7dff286663540c3b.zip | |
Diffstat (limited to 'src/mailman/utilities/uid.py')
| -rw-r--r-- | src/mailman/utilities/uid.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/mailman/utilities/uid.py b/src/mailman/utilities/uid.py index 6fceeb606..3d58cace5 100644 --- a/src/mailman/utilities/uid.py +++ b/src/mailman/utilities/uid.py @@ -52,16 +52,20 @@ class UniqueIDFactory: # the first use. self._uid_file = None self._lock_file = None - self._lock = None + self._lockobj = None + + @property + def _lock(self): + if self._lockobj is None: + # These will get automatically cleaned up by the test + # infrastructure. + self._uid_file = os.path.join(config.VAR_DIR, '.uid') + self._lock_file = self._uid_file + '.lock' + self._lockobj = Lock(self._lock_file) + return self._lockobj def new_uid(self, bytes=None): if layers.is_testing(): - if self._lock is None: - # These will get automatically cleaned up by the test - # infrastructure. - self._uid_file = os.path.join(config.VAR_DIR, '.uid') - self._lock_file = self._uid_file + '.lock' - self._lock = Lock(self._lock_file) # When in testing mode we want to produce predictable id, but we # need to coordinate this among separate processes. We could use # the database, but I don't want to add schema just to handle this |
