Skip to content

Commit 5ce84c0

Browse files
committed
Fix: git-storage-backend could try to commit several commits at once
There was an attempt to prevent that, but sadly, an Event was used instead of a Lock. This meant that when the first commit returned, all other pending were going through after that, instead of one by one. Lock is fair, as in, the first to acquire is the first to be released.
1 parent 2630741 commit 5ce84c0

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

truewiki/storage/git.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
GIT_USERNAME = None
1616
GIT_EMAIL = None
1717

18-
GIT_BUSY = asyncio.Event()
19-
GIT_BUSY.set()
18+
GIT_BUSY = asyncio.Lock()
2019

2120

2221
class OutOfProcessStorage:
@@ -108,8 +107,7 @@ def _init_repository(self):
108107
return _git
109108

110109
async def _run_out_of_process_async(self, folder, ssh_command, callback, func, *args):
111-
await GIT_BUSY.wait()
112-
GIT_BUSY.clear()
110+
await GIT_BUSY.acquire()
113111

114112
try:
115113
out_of_process = self.out_of_process_class((GIT_USERNAME, GIT_EMAIL), folder, ssh_command)
@@ -125,7 +123,7 @@ async def _run_out_of_process_async(self, folder, ssh_command, callback, func, *
125123
task = loop.run_in_executor(executor, getattr(out_of_process, func), *args)
126124
result = await task
127125
finally:
128-
GIT_BUSY.set()
126+
GIT_BUSY.release()
129127

130128
# Task indicated something went wrong; initiate a full reload.
131129
if result is False:

truewiki/storage/github.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ def _reload_done(self):
112112
super().reload()
113113

114114
def commit_done(self):
115+
super().commit_done()
115116
self._run_out_of_process(None, "push")
116117

117118
def get_history_url(self, page):

truewiki/storage/gitlab.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def _reload_done(self):
5555
super().reload()
5656

5757
def commit_done(self):
58+
super().commit_done()
5859
self._run_out_of_process(None, "push")
5960

6061
def get_history_url(self, page):

0 commit comments

Comments
 (0)