File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -28,10 +28,17 @@ def get(self):
2828 return self ._value
2929
3030
31- def MultiProcessValue (_pidFunc = os .getpid ):
31+ def MultiProcessValue (process_identifier = os .getpid ):
32+ """Returns a MmapedValue class based on a process_identifier function.
33+
34+ The 'process_identifier' function MUST comply with this simple rule:
35+ when called in simultaneously running processes it MUST return distinct values.
36+
37+ Using a different function than the default 'os.getpid' is at your own risk.
38+ """
3239 files = {}
3340 values = []
34- pid = {'value' : _pidFunc ()}
41+ pid = {'value' : process_identifier ()}
3542 # Use a single global lock when in multi-processing mode
3643 # as we presume this means there is no threading going on.
3744 # This avoids the need to also have mutexes in __MmapDict.
@@ -66,7 +73,7 @@ def __reset(self):
6673 self ._value = self ._file .read_value (self ._key )
6774
6875 def __check_for_pid_change (self ):
69- actual_pid = _pidFunc ()
76+ actual_pid = process_identifier ()
7077 if pid ['value' ] != actual_pid :
7178 pid ['value' ] = actual_pid
7279 # There has been a fork(), reset all the values.
You can’t perform that action at this time.
0 commit comments