File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -168,8 +168,10 @@ def Write(self, filename):
168
168
f .write ("\n " )
169
169
170
170
171
- # An integer id that is unique across this invocation of the program.
172
- _EVENT_ID = multiprocessing .Value ("i" , 1 )
171
+ # An integer id that is unique across this invocation of the program, to be set
172
+ # by the first Add event. We can't set it here since it results in leaked
173
+ # resources (see: https://issues.gerritcodereview.com/353656374).
174
+ _EVENT_ID = None
173
175
174
176
175
177
def _NextEventId ():
@@ -178,6 +180,12 @@ def _NextEventId():
178
180
Returns:
179
181
A unique, to this invocation of the program, integer id.
180
182
"""
183
+ global _EVENT_ID
184
+ if _EVENT_ID is None :
185
+ # There is a small chance of race condition - two parallel processes
186
+ # setting up _EVENT_ID. However, we expect TASK_COMMAND to happen before
187
+ # mp kicks in.
188
+ _EVENT_ID = multiprocessing .Value ("i" , 1 )
181
189
with _EVENT_ID .get_lock ():
182
190
val = _EVENT_ID .value
183
191
_EVENT_ID .value += 1
You can’t perform that action at this time.
0 commit comments