File tree 1 file changed +10
-3
lines changed 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -28,10 +28,17 @@ def get(self):
28
28
return self ._value
29
29
30
30
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
+ """
32
39
files = {}
33
40
values = []
34
- pid = {'value' : _pidFunc ()}
41
+ pid = {'value' : process_identifier ()}
35
42
# Use a single global lock when in multi-processing mode
36
43
# as we presume this means there is no threading going on.
37
44
# This avoids the need to also have mutexes in __MmapDict.
@@ -66,7 +73,7 @@ def __reset(self):
66
73
self ._value = self ._file .read_value (self ._key )
67
74
68
75
def __check_for_pid_change (self ):
69
- actual_pid = _pidFunc ()
76
+ actual_pid = process_identifier ()
70
77
if pid ['value' ] != actual_pid :
71
78
pid ['value' ] = actual_pid
72
79
# There has been a fork(), reset all the values.
You can’t perform that action at this time.
0 commit comments