Yohohohohohooho | Sanrei Aya
Sanrei Aya


Server : LiteSpeed
System : Linux barito.iixcp.rumahweb.net 5.14.0-611.49.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Apr 21 16:39:08 EDT 2026 x86_64
User : elvh3918 ( 1528)
PHP Version : 8.2.31
Disable Function : mail
Directory :  /usr/local/lib/python3.9/site-packages/celery/backends/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/local/lib/python3.9/site-packages/celery/backends/__pycache__/cassandra.cpython-39.pyc
a

��Sh6#�@s�dZddlZddlmZddlmZddlmZddlm	Z	z$ddl
Z
ddlZ
ddlZ
ddl
Z
WneyvdZ
Yn0dZee�Zd	Zd
ZdZdZd
ZdZdZdZdd�ZGdd�de	�ZdS)z@Apache Cassandra result store backend using the DataStax driver.�N)�states)�ImproperlyConfigured)�
get_logger�)�BaseBackend)�CassandraBackendz
You need to install the cassandra-driver library to
use the Cassandra backend.  See https://github.com/datastax/python-driver
z�
CASSANDRA_AUTH_PROVIDER you provided is not a valid auth_provider class.
See https://datastax.github.io/python-driver/api/cassandra/auth.html.
z(Cassandra backend improperly configured.z!Cassandra backend not configured.z�
INSERT INTO {table} (
    task_id, status, result, date_done, traceback, children) VALUES (
        %s, %s, %s, %s, %s, %s) {expires};
z]
SELECT status, result, date_done, traceback, children
FROM {table}
WHERE task_id=%s
LIMIT 1
z�
CREATE TABLE {table} (
    task_id text,
    status text,
    result blob,
    date_done timestamp,
    traceback blob,
    children blob,
    PRIMARY KEY ((task_id), date_done)
) WITH CLUSTERING ORDER BY (date_done DESC);
z
    USING TTL {0}
cCs
t|d�S)N�utf8)�bytes)�x�r�C/usr/local/lib/python3.9/site-packages/celery/backends/cassandra.py�buf_tCsr
csbeZdZdZdZdZdZd�fdd�	Zddd�Zdd	d
�Z	ddd�Z
d
d�Zd�fdd�	Z�Z
S)raGCassandra/AstraDB backend utilizing DataStax driver.

    Raises:
        celery.exceptions.ImproperlyConfigured:
            if module :pypi:`cassandra-driver` is not available,
            or not-exactly-one of the :setting:`cassandra_servers` and
            the :setting:`cassandra_secure_bundle_path` settings is set.
    NTcs�t�jfi|��tstt��|jj}|p4|�dd�|_|pF|�dd�|_	|p\|�dd�p\d|_
|pn|�dd�|_|p�|�dd�|_|�di�|_
|jp�|j	}	|	r�|jr�|js�tt��|jr�|j	r�tt��|p�|�dd�}
|
dur�t�|
�nd	|_|�d
�p�d}|�d��pd}ttj|tjj�|_ttj|tjj�|_d|_|�d
d�}
|�dd�}|
�r�|�r�ttj|
d�}|�s~tt��|fi|��|_d|_d|_d|_d|_t� �|_!dS)NZcassandra_serversZcassandra_secure_bundle_pathZcassandra_portiR#Zcassandra_keyspaceZcassandra_table�cassandra_optionsZcassandra_entry_ttl�Zcassandra_read_consistency�LOCAL_QUORUMZcassandra_write_consistencyZcassandra_auth_providerZcassandra_auth_kwargs)"�super�__init__�	cassandrar�E_NO_CASSANDRA�app�conf�get�servers�bundle_path�port�keyspace�tabler�E_CASSANDRA_NOT_CONFIGURED�E_CASSANDRA_MISCONFIGURED�	Q_EXPIRES�format�
cqlexpires�getattrZConsistencyLevelr�read_consistency�write_consistency�
auth_provider�auth�!E_NO_SUCH_CASSANDRA_AUTH_PROVIDER�_cluster�_session�_write_stmt�
_read_stmt�	threading�RLock�_lock)�selfrrrZ	entry_ttlrr�kwargsrZ
db_directions�expiresZ	read_consZ
write_consr%Zauth_kwargsZauth_provider_class��	__class__rrrXsV����zCassandraBackend.__init__FcCs�|jdurdS|j���z`�z|jdur<WW|j��dS|jrhtjj|jf|j|j	d�|j
��|_n$tjjfd|ji|j	d�|j
��|_|j�
|j�|_tj�tj|j|jd��|_|j|j_tj�tj|jd��|_|j|j_|�r0tj�tj|jd��}|j|_z|j�|�Wntj�y.Yn0Wn:tj�yl|jdu�rZ|j��d|_d|_�Yn0W|j��n|j��0dS)zjPrepare the connection for action.

        Arguments:
            write (bool): are we a writer?
        N)rr%Zsecure_connect_bundle)Zcloudr%)rr1)r) r)r.�acquire�releaserrZclusterZClusterrr%rr(r�connectr�queryZSimpleStatement�Q_INSERT_RESULTr rr!r*r$Zconsistency_level�Q_SELECT_RESULTr+r#�Q_CREATE_RESULT_TABLE�executeZ
AlreadyExistsZOperationTimedOut�shutdown)r/�writeZ	make_stmtrrr�_get_connection�sf


;
����
�����
�
	�


z CassandraBackend._get_connectioncKsV|jdd�|j�|j||t|�|��|j��t|�|��t|�|�|���f�dS)z1Store return value and state of an executed task.T)r=N)	r>r)r;r*r
�encoder�nowZcurrent_task_children)r/�task_id�result�state�	traceback�requestr0rrr�
_store_result�s
�zCassandraBackend._store_resultcCsdS)Nzcassandra://r)r/Zinclude_passwordrrr�as_uri�szCassandraBackend.as_uric
Csf|��|j�|j|f���}|s.tjdd�S|\}}}}}|�|||�|�||�|�|�|�d��S)z$Get task meta-data for a task by id.N)�statusrB)rArHrB�	date_donerD�children)	r>r)r;r+Zoner�PENDINGZmeta_from_decoded�decode)r/rA�resrHrBrIrDrJrrr�_get_task_meta_for�s�z#CassandraBackend._get_task_meta_forrcs2|sin|}|�|j|j|jd��t��||�S)N)rrr)�updaterrrr�
__reduce__)r/�argsr0r2rrrP�s��zCassandraBackend.__reduce__)NNNNNN)F)NN)T)rN)�__name__�
__module__�__qualname__�__doc__rrZsupports_autoexpirerr>rFrGrNrP�
__classcell__rrr2rrGs
�6
I�

r)rUr,ZceleryrZcelery.exceptionsrZcelery.utils.logr�baserrZcassandra.authZcassandra.clusterZcassandra.query�ImportError�__all__rR�loggerrr'rrr8r9r:rr
rrrrr�<module>s0


Yohohohohohooho | Sanrei Aya