22from abc import ABC , abstractmethod
33from collections import Counter
44from dataclasses import dataclass , field
5- from enum import Enum , auto
5+ from enum import Enum
66from typing import Any , Callable , Dict , List , Optional , Set , Union
77from zlib import crc32
88
@@ -1378,23 +1378,6 @@ class TaskResult(BaseModel):
13781378 result : Any = Field (..., description = "The result of the task." )
13791379
13801380
1381- @PublicAPI (stability = "alpha" )
1382- class AsyncCapability (Enum ):
1383- """
1384- Enum defining different async capabilities a TaskProcessor can support.
1385-
1386- Each capability represents an async operation that an adapter may or may not
1387- support. Use TaskProcessorAdapter.supports_async_capability() to check if
1388- a specific capability is available before using the corresponding async method.
1389- """
1390-
1391- ENQUEUE_TASK = auto () # Ability to enqueue tasks asynchronously
1392- GET_TASK_STATUS = auto () # Ability to retrieve task status asynchronously
1393- CANCEL_TASK = auto () # Ability to cancel tasks asynchronously
1394- GET_METRICS = auto () # Ability to retrieve metrics asynchronously
1395- HEALTH_CHECK = auto () # Ability to perform health checks asynchronously
1396-
1397-
13981381@PublicAPI (stability = "alpha" )
13991382class TaskProcessorAdapter (ABC ):
14001383 """
@@ -1408,44 +1391,8 @@ def __init__(self, *args, **kwargs):
14081391 """
14091392 Initialize the TaskProcessorAdapter.
14101393
1411- Sets up an empty set of async capabilities. Subclasses should add their
1412- supported async capabilities to self._async_capabilities in their __init__
1413- method.
1414- """
1415- self ._async_capabilities : Set [AsyncCapability ] = set ()
1416-
1417- @property
1418- def async_capabilities (self ) -> Set [AsyncCapability ]:
1419- """
1420- Get the set of async capabilities supported by this adapter.
1421-
1422- Returns:
1423- Set[AsyncCapability]: A copy of the set containing all async capabilities
1424- supported by this adapter. Modifying the returned set will not affect
1425- the adapter's capabilities.
1426- """
1427- return self ._async_capabilities .copy ()
1428-
1429- def supports_async_capability (self , capability : AsyncCapability ) -> bool :
14301394 """
1431- Check if this adapter supports a specific async capability.
1432-
1433- Args:
1434- capability: The AsyncCapability enum value to check for.
1435-
1436- Returns:
1437- bool: True if the capability is supported, False otherwise.
1438- """
1439- return capability in self ._async_capabilities
1440-
1441- def supports_any_async (self ) -> bool :
1442- """
1443- Check if this adapter supports any async operations.
1444-
1445- Returns:
1446- bool: True if at least one async capability is supported, False if this is a sync-only adapter.
1447- """
1448- return len (self ._async_capabilities ) > 0
1395+ pass
14491396
14501397 @abstractmethod
14511398 def initialize (self , consumer_concurrency : int = DEFAULT_CONSUMER_CONCURRENCY ):
@@ -1574,13 +1521,8 @@ async def enqueue_task_async(
15741521 TaskResult: Object containing task ID, status, and other metadata.
15751522
15761523 Raises:
1577- NotImplementedError: If async enqueue is not supported by this adapter.
1524+ NotImplementedError: If subclass didn't implement enqueue_task_async function
15781525 """
1579- if not self .supports_async_capability (AsyncCapability .ENQUEUE_TASK ):
1580- raise NotImplementedError (
1581- f"{ self .__class__ .__name__ } does not support async task enqueueing. "
1582- f"Use enqueue_task_sync() instead or check supports_async_capability() first."
1583- )
15841526
15851527 raise NotImplementedError ("Subclass must implement enqueue_task_async function" )
15861528
@@ -1595,13 +1537,8 @@ async def get_task_status_async(self, task_id: str) -> TaskResult:
15951537 TaskResult: Object containing current task status, result, and other metadata.
15961538
15971539 Raises:
1598- NotImplementedError: If async status retrieval is not supported by this adapter.
1540+ NotImplementedError: If subclass didn't implement get_task_status_async function
15991541 """
1600- if not self .supports_async_capability (AsyncCapability .GET_TASK_STATUS ):
1601- raise NotImplementedError (
1602- f"{ self .__class__ .__name__ } does not support async task status retrieval. "
1603- f"Use get_task_status_sync() instead or check supports_async_capability() first."
1604- )
16051542
16061543 raise NotImplementedError (
16071544 "Subclass must implement get_task_status_async function"
@@ -1615,13 +1552,8 @@ async def cancel_task_async(self, task_id: str):
16151552 task_id: Unique identifier of the task to cancel.
16161553
16171554 Raises:
1618- NotImplementedError: If async task cancellation is not supported by this adapter.
1555+ NotImplementedError: If subclass didn't implement cancel_task_async function
16191556 """
1620- if not self .supports_async_capability (AsyncCapability .CANCEL_TASK ):
1621- raise NotImplementedError (
1622- f"{ self .__class__ .__name__ } does not support async task cancellation. "
1623- f"Check supports_async_capability() first."
1624- )
16251557
16261558 raise NotImplementedError ("Subclass must implement cancel_task_async function" )
16271559
@@ -1633,13 +1565,8 @@ async def get_metrics_async(self) -> Dict[str, Any]:
16331565 Dict[str, Any]: Adapter-specific metrics data.
16341566
16351567 Raises:
1636- NotImplementedError: If async metrics retrieval is not supported by this adapter.
1568+ NotImplementedError: If subclass didn't implement get_metrics_async function
16371569 """
1638- if not self .supports_async_capability (AsyncCapability .GET_METRICS ):
1639- raise NotImplementedError (
1640- f"{ self .__class__ .__name__ } does not support async metrics retrieval. "
1641- f"Check supports_async_capability() first."
1642- )
16431570
16441571 raise NotImplementedError ("Subclass must implement get_metrics_async function" )
16451572
@@ -1651,13 +1578,8 @@ async def health_check_async(self) -> List[Dict]:
16511578 List[Dict]: Health status information for workers/components.
16521579
16531580 Raises:
1654- NotImplementedError: If async health check is not supported by this adapter.
1581+ NotImplementedError: If subclass didn't implement health_check_async function
16551582 """
1656- if not self .supports_async_capability (AsyncCapability .HEALTH_CHECK ):
1657- raise NotImplementedError (
1658- f"{ self .__class__ .__name__ } does not support async health check. "
1659- f"Check supports_async_capability() first."
1660- )
16611583
16621584 raise NotImplementedError ("Subclass must implement health_check_async function" )
16631585
0 commit comments