streamlit-octostar-utils 0.4.2.dev24__tar.gz → 0.4.2.dev25__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/PKG-INFO +1 -1
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/pyproject.toml +1 -1
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/api_crafter/celery.py +39 -30
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/LICENSE +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/README.md +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/__init__.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/api_crafter/__init__.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/api_crafter/contents.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/api_crafter/fastapi.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/api_crafter/nifi.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/api_crafter/parallelism.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/api_crafter/parser/__init__.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/api_crafter/parser/combine_fields.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/api_crafter/parser/entities_parser.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/api_crafter/parser/generics.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/api_crafter/parser/info.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/api_crafter/parser/linkchart_functions.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/api_crafter/parser/matches.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/api_crafter/parser/parameters.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/api_crafter/parser/rules.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/api_crafter/parser/signals.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/core/__init__.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/core/dict.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/core/filetypes.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/core/threading/__init__.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/core/threading/key_queue.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/core/timestamp.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/nlp/__init__.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/nlp/custom_recognizers.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/nlp/language.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/nlp/ner.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/octostar/__init__.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/octostar/client.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/octostar/context.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/octostar/permissions.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/ontology/__init__.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/ontology/inheritance.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/ontology/relationships.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/ontology/validation.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/style/__init__.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/style/common.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/threading/__init__.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/threading/async_task_manager.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/threading/session_callback_manager.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev24 → streamlit_octostar_utils-0.4.2.dev25}/streamlit_octostar_utils/threading/session_state_hot_swapper.py +0 -0
|
@@ -129,7 +129,10 @@ class CeleryExecutor(object):
|
|
|
129
129
|
self.get_thread_pool = None
|
|
130
130
|
self.set_thread_pool = None
|
|
131
131
|
self.io_thread_pool = None
|
|
132
|
-
self.
|
|
132
|
+
self.queue_semaphores = {
|
|
133
|
+
k: threading.Semaphore(v.max_tasks_in_queue) if v.max_tasks_in_queue else None
|
|
134
|
+
for k, v in self.queue_config.items()
|
|
135
|
+
}
|
|
133
136
|
|
|
134
137
|
# Folder setup
|
|
135
138
|
self.base_folder = Path(base_folder).resolve()
|
|
@@ -576,36 +579,23 @@ class CeleryExecutor(object):
|
|
|
576
579
|
|
|
577
580
|
return decorator
|
|
578
581
|
|
|
579
|
-
async def send_task(self, task_fn, args=
|
|
582
|
+
async def send_task(self, task_fn, args=None, kwargs=None, **options) -> str:
|
|
583
|
+
args = args if args is not None else []
|
|
584
|
+
kwargs = kwargs if kwargs is not None else {}
|
|
580
585
|
if self.app.conf.task_always_eager and "dev_preload" not in self.app.conf:
|
|
581
586
|
self.preload_on_worker_init()
|
|
582
587
|
self.app.conf.dev_preload = True
|
|
583
588
|
|
|
584
|
-
def
|
|
589
|
+
def _check_queue_llen(queue_name):
|
|
585
590
|
if self._queue_stalled.get(queue_name, False):
|
|
586
591
|
raise CeleryExecutor.QueueStalledException(
|
|
587
592
|
f"Queue '{queue_name}' is stalled. Service temporarily unavailable."
|
|
588
593
|
)
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
reserved_count = int(self.redis_client.get(reservation_key) or 0)
|
|
595
|
-
total_count = queue_count + reserved_count
|
|
596
|
-
if total_count >= limit:
|
|
597
|
-
raise CeleryExecutor.QueueFullException(
|
|
598
|
-
f"Queue '{queue_name}' has reached its limit of {limit} tasks!"
|
|
599
|
-
)
|
|
600
|
-
self.redis_client.incr(reservation_key)
|
|
601
|
-
return True
|
|
602
|
-
return False
|
|
603
|
-
|
|
604
|
-
def _release_queue_slot(queue_name):
|
|
605
|
-
limit = self.queue_config[queue_name].max_tasks_in_queue
|
|
606
|
-
if limit:
|
|
607
|
-
reservation_key = f"queue:reserved:{queue_name}"
|
|
608
|
-
self.redis_client.decr(reservation_key)
|
|
594
|
+
if self.redis_client.llen(queue_name) >= self.queue_config[queue_name].max_tasks_in_queue:
|
|
595
|
+
raise CeleryExecutor.QueueFullException(
|
|
596
|
+
f"Queue '{queue_name}' has reached its limit of "
|
|
597
|
+
f"{self.queue_config[queue_name].max_tasks_in_queue} tasks!"
|
|
598
|
+
)
|
|
609
599
|
|
|
610
600
|
def _write_task_data(in_folder, task_args, task_kwargs, task_id):
|
|
611
601
|
serialized_data = CelerySerialized(
|
|
@@ -629,11 +619,22 @@ class CeleryExecutor(object):
|
|
|
629
619
|
queue_name = self.app.conf.task_default_routing_key
|
|
630
620
|
queue_name = getattr(task_fn, "queue", queue_name)
|
|
631
621
|
queue_name = options.get("queue", queue_name)
|
|
632
|
-
|
|
622
|
+
|
|
623
|
+
sem = self.queue_semaphores.get(queue_name)
|
|
624
|
+
acquired = False
|
|
625
|
+
if sem is not None:
|
|
626
|
+
if not sem.acquire(blocking=False):
|
|
627
|
+
raise CeleryExecutor.QueueFullException(
|
|
628
|
+
f"Queue '{queue_name}' has reached its limit of "
|
|
629
|
+
f"{self.queue_config[queue_name].max_tasks_in_queue} tasks!"
|
|
630
|
+
)
|
|
631
|
+
acquired = True
|
|
632
|
+
|
|
633
633
|
try:
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
634
|
+
if acquired:
|
|
635
|
+
await asyncio.get_running_loop().run_in_executor(
|
|
636
|
+
self.set_thread_pool, _check_queue_llen, queue_name
|
|
637
|
+
)
|
|
637
638
|
await asyncio.get_running_loop().run_in_executor(
|
|
638
639
|
self.io_thread_pool,
|
|
639
640
|
_write_task_data,
|
|
@@ -652,9 +653,15 @@ class CeleryExecutor(object):
|
|
|
652
653
|
logger.info(f"Cancelling task {task_id} due to disconnect!")
|
|
653
654
|
await self.terminate_task(task_id)
|
|
654
655
|
raise
|
|
656
|
+
except Exception:
|
|
657
|
+
try:
|
|
658
|
+
await self.terminate_task(task_id)
|
|
659
|
+
except Exception:
|
|
660
|
+
pass
|
|
661
|
+
raise
|
|
655
662
|
finally:
|
|
656
|
-
if
|
|
657
|
-
|
|
663
|
+
if acquired:
|
|
664
|
+
sem.release()
|
|
658
665
|
return task_id
|
|
659
666
|
|
|
660
667
|
async def terminate_task(self, task_id):
|
|
@@ -737,7 +744,9 @@ class CeleryExecutor(object):
|
|
|
737
744
|
)
|
|
738
745
|
return result
|
|
739
746
|
|
|
740
|
-
async def send_and_wait_task(self, task_fn, args=
|
|
747
|
+
async def send_and_wait_task(self, task_fn, args=None, kwargs=None, timeout=60, **options):
|
|
748
|
+
args = args if args is not None else []
|
|
749
|
+
kwargs = kwargs if kwargs is not None else {}
|
|
741
750
|
task_id = await self.send_task(task_fn, args, kwargs, **options)
|
|
742
751
|
ready = False
|
|
743
752
|
state = None
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|