Skip to content

Commit

Permalink
fix: remove useless lock from EventWriteThread
Browse files Browse the repository at this point in the history
  • Loading branch information
mutantsan committed Nov 7, 2024
1 parent afd896e commit 8e5b4df
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions ckanext/event_audit/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def __init__(self, queue: queue.Queue[types.Event]):
threading.Thread.__init__(self)
self.queue = queue
self.data = types.ThreadData(last_push=datetime.now(tz.utc), events=[])
self.lock = threading.Lock()

def run(self):
while True:
Expand All @@ -37,13 +36,12 @@ def run(self):
) >= config.get_batch_size() or self._is_time_to_push(
self.data["last_push"]
):
with self.lock:
repo = utils.get_active_repo()
repo = utils.get_active_repo()

repo.write_events(self.data["events"])
repo.write_events(self.data["events"])

self.data["events"] = []
self.data["last_push"] = datetime.now(tz.utc)
self.data["events"] = []
self.data["last_push"] = datetime.now(tz.utc)

self.queue.task_done()

Expand Down

0 comments on commit 8e5b4df

Please sign in to comment.