Skip to content

Commit

Permalink
Merge branch 'master' into release-0.18.x
Browse files Browse the repository at this point in the history
  • Loading branch information
tomachalek committed Jul 25, 2024
2 parents b2cdf37 + 6b50847 commit 632edbf
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/action/model/concordance/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from typing import Any, Dict, List, Optional, Tuple, Union
import asyncio
import logging
from sanic import Sanic

import conclib
import plugins
Expand Down Expand Up @@ -308,6 +309,7 @@ async def _store_conc_params(self) -> Tuple[List[str], Optional[int]]:
ID of the stored operation (or the current ID of nothing was stored),
UNIX timestamp of stored history item (or None)
"""
application = Sanic.get_app('kontext')
with plugins.runtime.QUERY_PERSISTENCE as qp:
prev_data = self._active_q_data if self._active_q_data is not None else {}
use_history, curr_data = self.export_query_data()
Expand All @@ -317,8 +319,9 @@ async def _store_conc_params(self) -> Tuple[List[str], Optional[int]]:

# archive the concordance, it may take a bit longer, so we
# do this as a non-blocking operation
task = asyncio.create_task(self._archive_conc(user_id, qp_store_id))
task.add_done_callback(lambda r: None) # we need this to ensure completion
task = application.add_task(self._archive_conc(user_id, qp_store_id))
task.add_done_callback(lambda r: logging.getLogger(__name__).debug(
f'finished archiving of conc {qp_store_id}'))

history_ts = await self._save_query_to_history(ans[0], curr_data) if use_history else None
lines_groups = prev_data.get('lines_groups', self._lines_groups.serialize())
Expand All @@ -333,8 +336,9 @@ async def _store_conc_params(self) -> Tuple[List[str], Optional[int]]:
qp_store_id = await qp.store(self.session_get('user', 'id'), curr_data=curr, prev_data=prev)
# archive the concordance, it may take a bit longer, so we
# do this as a non-blocking operation
task = asyncio.create_task(self._archive_conc(user_id, qp_store_id))
task.add_done_callback(lambda r: None) # we need this to ensure completion
task = application.add_task(self._archive_conc(user_id, qp_store_id))
task.add_done_callback(lambda r: logging.getLogger(__name__).debug(
f'finished archiving of conc {qp_store_id}'))
ans.append(qp_store_id)
return ans, history_ts

Expand Down

0 comments on commit 632edbf

Please sign in to comment.