+
    üÐjA  ã                   ó€   € R t ^ RIHt ^ RIHtHt  ! R R]4      t ! R R4      t ! R R4      t	 ! R	 R
4      t
RR
.tR# )zg
An asynchronous mapping to U{DB-API
2.0<http://www.python.org/topics/database/DatabaseAPI-2.0.html>}.
)Úthreads)ÚlogÚreflectc                   ó   € ] tR t^tRtRtR# )ÚConnectionLostzV
This exception means that a db connection has been lost.  Client code may
try again.
© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__r   ó    Ú;/usr/lib/python3/dist-packages/twisted/enterprise/adbapi.pyr   r      s   † õr   r   c                   óB   a € ] tR t^t o RtR tR tR tR tR t	Rt
V tR# )	Ú
Connectionzù
A wrapper for a DB-API connection instance.

The wrapper passes almost everything to the wrapped connection and so has
the same API. However, the L{Connection} knows about its pool and also
handle reconnecting should when the real connection dies.
c                ó@   € Wn         R V n        V P                  4        R # ©N)Ú_poolÚ_connectionÚ	reconnect)ÚselfÚpools   &&r   Ú__init__ÚConnection.__init__   s   € ØŒ
ØˆÔØ�‰Ör   c                ó   € R # r   r   ©r   s   &r   ÚcloseÚConnection.close$   s   € ñ 	r   c                ó�  € V P                   P                  '       g   V P                  P                  4        R #  V P                  P                  4        V P                  P	                  4       pVP                  V P                   P                  4       VP                  4        V P                  P                  4        R #   \         d    \        P                  ! R R4        Mi ; iT P                   P                  T P                  4       T P                   P                  '       d   \        P                  ! R4       \        4       h)NúRollback failedzConnection lost.)r   r   r   ÚrollbackÚcursorÚexecuteÚgood_sqlr   ÚcommitÚBaseExceptionr   ÚerrÚ
disconnectÚnoisyÚmsgr   )r   Úcurss   & r   r!   ÚConnection.rollback.   sä   € Ø�z‰z×#×#Ð#Ø×Ñ×%Ñ%Ô'Ùð	-Ø×Ñ×%Ñ%Ô'Ø×#Ñ#×*Ñ*Ó,ˆDØ�L‰L˜Ÿ™×,Ñ,Ô-Ø�J‰JŒLØ×Ñ×#Ñ#Ô%ÙøÜô 	-Ü�GŠG�DÐ+Ö,ð	-úð 	�
‰
×Ñ˜d×.Ñ.Ô/à�:‰:××ÐÜ�GŠGÐ&Ô'äÓÐs   ºBB? Â?"C$Ã#C$c                óª   € V P                   e&   V P                  P                  V P                   4       V P                  P                  4       V n         R # r   )r   r   r(   Úconnectr   s   &r   r   ÚConnection.reconnectD   s;   € Ø×ÑÒ'Ø�J‰J×!Ñ! $×"2Ñ"2Ô3ØŸ:™:×-Ñ-Ó/ˆÖr   c                ó.   € \        V P                  V4      # r   )Úgetattrr   ©r   Únames   &&r   Ú__getattr__ÚConnection.__getattr__I   s   € Ü�t×'Ñ'¨Ó.Ð.r   )r   r   N)r   r	   r
   r   r   r   r   r!   r   r4   r   Ú__classdictcell__©Ú__classdict__s   @r   r   r      s(   ø‡ € ñòò
òò,0÷
/ð /r   r   c                   óF   a € ] tR t^Mt o RtRtR tR tR tR t	R t
RtV tR# )	ÚTransactiona  
A lightweight wrapper for a DB-API 'cursor' object.

Relays attribute access to the DB cursor. That is, you can call
C{execute()}, C{fetchall()}, etc., and they will be called on the
underlying DB-API cursor object. Attributes will also be retrieved from
there.
Nc                ó>   € Wn         W n        V P                  4        R # r   )r   r   Úreopen)r   r   Ú
connections   &&&r   r   ÚTransaction.__init__Y   s   € ØŒ
Ø%ÔØ�‰Žr   c                óL   € V P                   pR V n         VP                  4        R # r   )Ú_cursorr   )r   r@   s   & r   r   ÚTransaction.close^   s   € Ø—,‘,ˆØˆŒØ�‰Žr   c                óÒ  € V P                   e   V P                  4         V P                  P                  4       V n         R #   \         d8    T P
                  P                  '       g   h \        P                  ! R R4        Mi ; iT P
                  P                  '       d   \        P                  ! R4       T P                  4        T P                  P                  4       T n         R # )NzCursor creation failedzConnection lost, reconnecting)r@   r   r   r"   r&   r   r   r   r'   r)   r*   r   s   &r   r<   ÚTransaction.reopenc   s£   € Ø�<‰<Ò#Ø�J‰JŒLð	8Ø×+Ñ+×2Ñ2Ó4ˆDŒLÙøÜô 	8Ø—:‘:×'×'Ð'Øä—’˜Ð6Ö7ð		8úð �:‰:××ÐÜ�GŠGÐ3Ô4à�‰ÔØ×'Ñ'×.Ñ.Ó0ˆŽs    A Á&BÁ(BÂBc                óH   € V P                   P                  4        R V n        R # r   )r   r   r@   r   s   &r   r   ÚTransaction.reconnectv   s   € Ø×Ñ×"Ñ"Ô$ØˆŽr   c                ó.   € \        V P                  V4      # r   )r1   r@   r2   s   &&r   r4   ÚTransaction.__getattr__z   s   € Ü�t—|‘| TÓ*Ð*r   )r   r@   r   )r   r	   r
   r   r   r@   r   r   r<   r   r4   r   r6   r7   s   @r   r:   r:   M   s/   ø‡ € ñð €Gòò
ò
1ò&÷+ð +r   r:   c                   óÜ   a € ] tR t^~t o RtRP                  4       tRt^t^t	Rt
RtRtRtRt]t]tRtR tR tR tR	 tR
 tR tR tR tR tR tR tR tR t R t!R t"R t#R t$R t%Rt&V t'R# )ÚConnectionPoolaV  
Represent a pool of connections to a DB-API 2.0 compliant database.

@ivar connectionFactory: factory for connections, default to L{Connection}.
@type connectionFactory: any callable.

@ivar transactionFactory: factory for transactions, default to
    L{Transaction}.
@type transactionFactory: any callable

@ivar shutdownID: L{None} or a handle on the shutdown event trigger which
    will be used to stop the connection pool workers when the reactor
    stops.

@ivar _reactor: The reactor which will be used to schedule startup and
    shutdown events.
@type _reactor: L{IReactorCore} provider
z-min max name noisy openfun reconnect good_sqlFNzselect 1c                óR  € Wn         \        P                  ! V4      V n        \	        V P                  RR4      R8w  d   \
        P                  ! R4       \	        V P                  R^ 4      ^8  d   \
        P                  ! R4       VP                  RR4      pVf   ^ RIH	p W@n
        W n        W0n        V P                   F$  pR	V 2pWc9   g   K  \        WW6,          4       W6 K&  	  \        V P                  V P                   4      V n        \!        V P                  V P                   4      V n        / V n        ^ R
IHpHp VP*                  V n        VP/                  V P                  V P                   4      V n        V P                  P1                  V P2                  4      V n        R# )a  
Create a new L{ConnectionPool}.

Any positional or keyword arguments other than those documented here
are passed to the DB-API object when connecting. Use these arguments to
pass database names, usernames, passwords, etc.

@param dbapiName: an import string to use to obtain a DB-API compatible
    module (e.g. C{'pyPgSQL.PgSQL'})

@keyword cp_min: the minimum number of connections in pool (default 3)

@keyword cp_max: the maximum number of connections in pool (default 5)

@keyword cp_noisy: generate informational log messages during operation
    (default C{False})

@keyword cp_openfun: a callback invoked after every C{connect()} on the
    underlying DB-API object. The callback is passed a new DB-API
    connection object. This callback can setup per-connection state
    such as charset, timezone, etc.

@keyword cp_reconnect: detect connections which have failed and reconnect
    (default C{False}). Failed connections may result in
    L{ConnectionLost} exceptions, which indicate the query may need to
    be re-sent.

@keyword cp_good_sql: an sql query which should always succeed and change
    no state (default C{'select 1'})

@keyword cp_reactor: use this reactor instead of the global reactor
    (added in Twisted 10.2).
@type cp_reactor: L{IReactorCore} provider
ÚapilevelNz2.0z'DB API module not DB API 2.0 compliant.Úthreadsafetyz+DB API module not sufficiently thread-safe.Ú
cp_reactor)ÚreactorÚcp_)Ú
threadableÚ
threadpool)Ú	dbapiNamer   ÚnamedModuleÚdbapir1   r   r*   ÚpopÚtwisted.internetrN   Ú_reactorÚconnargsÚconnkwÚCP_ARGSÚsetattrÚminÚmaxÚconnectionsÚtwisted.pythonrP   rQ   ÚgetThreadIDÚthreadIDÚ
ThreadPoolÚcallWhenRunningÚ_startÚstartID)	r   rR   rX   rY   rN   ÚargÚcpArgrP   rQ   s	   &&*,     r   r   ÚConnectionPool.__init__¤   s6  € ðF #ŒÜ×(Ò(¨Ó3ˆŒ
ä�4—:‘:˜z¨4Ó0°EÔ9Ü�GŠGÐ=Ô>ä�4—:‘:˜~¨qÓ1°AÔ5Ü�GŠGÐAÔBà—*‘*˜\¨4Ó0ˆØŠ?Ý0ØŒà ŒØŒà—<”<ˆCØ˜#˜�KˆEØŽÜ˜ 6¥=Ô1Ø’Mñ	  ô �t—x‘x §¡Ó*ˆŒÜ�t—x‘x §¡Ó*ˆŒð ˆÔ÷ 	:à"×.Ñ.ˆŒØ$×/Ñ/°·±¸$¿(¹(ÓCˆŒØ—}‘}×4Ñ4°T·[±[ÓAˆŽr   c                ó0   € R V n         V P                  4       # r   )re   Ústartr   s   &r   rd   ÚConnectionPool._startë   s   € ØˆŒØ�z‰z‹|Ðr   c                óÈ   € V P                   '       gP   V P                  P                  4        V P                  P	                  RRV P
                  4      V n        RV n         R# R# )zp
Start the connection pool.

If you are using the reactor normally, this function does *not*
need to be called.
ÚduringÚshutdownTN)ÚrunningrQ   rj   rW   ÚaddSystemEventTriggerÚ
finalCloseÚ
shutdownIDr   s   &r   rj   ÚConnectionPool.startï   sL   € ð �|�|ˆ|Ø�O‰O×!Ñ!Ô#Ø"Ÿm™m×AÑAØ˜* d§o¡oóˆDŒOð  ˆDŽLñ r   c                óx   € \         P                  ! V P                  V P                  V P                  V.VO5/ VB # )a}  
Execute a function with a database connection and return the result.

@param func: A callable object of one argument which will be executed
    in a thread with a connection from the pool. It will be passed as
    its first argument a L{Connection} instance (whose interface is
    mostly identical to that of a connection object for your DB-API
    module of choice), and its results will be returned as a
    L{Deferred}. If the method raises an exception the transaction will
    be rolled back. Otherwise, the transaction will be committed.
    B{Note} that this function is B{not} run in the main thread: it
    must be threadsafe.

@param args: positional arguments to be passed to func

@param kw: keyword arguments to be passed to func

@return: a L{Deferred} which will fire the return value of
    C{func(Transaction(...), *args, **kw)}, or a
    L{twisted.python.failure.Failure}.
)r   ÚdeferToThreadPoolrW   rQ   Ú_runWithConnection)r   ÚfuncÚargsÚkws   &&*,r   ÚrunWithConnectionÚ ConnectionPool.runWithConnectioný   s>   € ô, ×(Ò(Ø�M‰M˜4Ÿ?™?¨D×,CÑ,CÀTð
ØLPò
ØTVñ
ð 	
r   c                óô   € V P                  V 4      p V! V.VO5/ VB pVP                  4        V#   \         d<     TP                  4        h   \         d    \        P
                  ! R R4        h i ; ii ; i©Nr    )ÚconnectionFactoryr%   r&   r!   r   r'   )r   rw   rx   ry   ÚconnÚresults   &&*,  r   rv   Ú!ConnectionPool._runWithConnection  s~   € Ø×%Ñ% dÓ+ˆð		Ù˜$Ð, Ò,¨Ñ,ˆFØ�K‰KŒMØˆMøÜô 	ð1Ø—‘”ð øô !ô 1Ü—’˜Ð/Õ0Øð1úð	ús,   “1 ±A7½AÁA7Á"A3Á0A7Á2A3Á3A7c                óx   € \         P                  ! V P                  V P                  V P                  V.VO5/ VB # )a(  
Interact with the database and return the result.

The 'interaction' is a callable object which will be executed in a
thread using a pooled connection. It will be passed an L{Transaction}
object as an argument (whose interface is identical to that of the
database cursor for your DB-API module of choice), and its results will
be returned as a L{Deferred}. If running the method raises an
exception, the transaction will be rolled back. If the method returns a
value, the transaction will be committed.

NOTE that the function you pass is *not* run in the main thread: you
may have to worry about thread-safety in the function you pass to this
if it tries to use non-local objects.

@param interaction: a callable object whose first argument is an
    L{adbapi.Transaction}.

@param args: additional positional arguments to be passed to
    interaction

@param kw: keyword arguments to be passed to interaction

@return: a Deferred which will fire the return value of
    C{interaction(Transaction(...), *args, **kw)}, or a
    L{twisted.python.failure.Failure}.
)r   ru   rW   rQ   Ú_runInteraction)r   Úinteractionrx   ry   s   &&*,r   ÚrunInteractionÚConnectionPool.runInteraction$  sE   € ô8 ×(Ò(Ø�M‰MØ�O‰OØ× Ñ Øð	
ð
 ò
ð ñ
ð 	
r   c                óB   € V P                   ! V P                  .VO5/ VB # )añ  
Execute an SQL query and return the result.

A DB-API cursor which will be invoked with C{cursor.execute(*args,
**kw)}. The exact nature of the arguments will depend on the specific
flavor of DB-API being used, but the first argument in C{*args} be an
SQL statement. The result of a subsequent C{cursor.fetchall()} will be
fired to the L{Deferred} which is returned. If either the 'execute' or
'fetchall' methods raise an exception, the transaction will be rolled
back and a L{twisted.python.failure.Failure} returned.

The C{*args} and C{**kw} arguments will be passed to the DB-API
cursor's 'execute' method.

@return: a L{Deferred} which will fire the return value of a DB-API
    cursor's 'fetchall' method, or a L{twisted.python.failure.Failure}.
)r…   Ú	_runQuery©r   rx   ry   s   &*,r   ÚrunQueryÚConnectionPool.runQueryI  s#   € ð$ ×"Ò" 4§>¡>Ð?°DÒ?¸BÑ?Ð?r   c                óB   € V P                   ! V P                  .VO5/ VB # )aÛ  
Execute an SQL query and return L{None}.

A DB-API cursor which will be invoked with C{cursor.execute(*args,
**kw)}. The exact nature of the arguments will depend on the specific
flavor of DB-API being used, but the first argument in C{*args} will be
an SQL statement. This method will not attempt to fetch any results
from the query and is thus suitable for C{INSERT}, C{DELETE}, and other
SQL statements which do not return values. If the 'execute' method
raises an exception, the transaction will be rolled back and a
L{Failure} returned.

The C{*args} and C{*kw} arguments will be passed to the DB-API cursor's
'execute' method.

@return: a L{Deferred} which will fire with L{None} or a
    L{twisted.python.failure.Failure}.
)r…   Ú_runOperationr‰   s   &*,r   ÚrunOperationÚConnectionPool.runOperation]  s%   € ð& ×"Ò" 4×#5Ñ#5ÐC¸ÒCÀÑCÐCr   c                ó  € V P                   '       d-   V P                  P                  V P                   4       RV n         V P                  '       d-   V P                  P                  V P                  4       RV n        V P	                  4        R# )z3
Close all pool connections and shutdown the pool.
N)rr   rW   ÚremoveSystemEventTriggerre   rq   r   s   &r   r   ÚConnectionPool.closer  sZ   € ð �?�?ˆ?Ø�M‰M×2Ñ2°4·?±?ÔCØ"ˆDŒOØ�<�<ˆ<Ø�M‰M×2Ñ2°4·<±<Ô@ØˆDŒLØ�‰Ör   c                óî   € RV n         V P                  P                  4        RV n        V P                  P                  4        F  pV P                  V4       K  	  V P                  P                  4        R# )z5
This should only be called by the shutdown trigger.
NF)rr   rQ   Ústopro   r^   ÚvaluesÚ_closeÚclear©r   r   s   & r   rq   ÚConnectionPool.finalClose~  sY   € ð ˆŒØ�‰×ÑÔØˆŒØ×$Ñ$×+Ñ+Ö-ˆDØ�K‰K˜Öñ .à×Ñ×ÑÖ r   c                óˆ  € V P                  4       pV P                  P                  V4      pVf“   V P                  '       d$   \        P
                  ! RV P                   24       V P                  P                  ! V P                  / V P                  B pV P                  e   V P                  V4       W P                  V&   V# )a]  
Return a database connection when one becomes available.

This method blocks and should be run in a thread from the internal
threadpool. Don't call this method directly from non-threaded code.
Using this method outside the external threadpool may exceed the
maximum number of connections in the pool.

@return: a database connection from the pool.
zadbapi connecting: )ra   r^   Úgetr)   r   r*   rR   rT   r.   rX   rY   Úopenfun)r   Útidr   s   &  r   r.   ÚConnectionPool.connect‰  s–   € ð �m‰m‹oˆØ×Ñ×#Ñ# CÓ(ˆØŠ<Ø�z�zˆzÜ—’Ð-¨d¯n©nÐ-=Ð>Ô?Ø—:‘:×%Ò% t§}¡}ÐD¸¿¹ÑDˆDØ�|‰|Ò'Ø—‘˜TÔ"Ø$(×Ñ˜SÑ!Øˆr   c                óÀ   € V P                  4       pWP                  P                  V4      Jd   \        R4      hVe!   V P	                  V4       V P                  V R# R# )zô
Disconnect a database connection associated with this pool.

Note: This function should only be used by the same thread which called
L{ConnectionPool.connect}. As with C{connect}, this function is not
used in normal non-threaded Twisted code.
zwrong connection for threadN)ra   r^   r›   Ú	Exceptionr–   )r   r   r�   s   && r   r(   ÚConnectionPool.disconnect   sW   € ð �m‰m‹oˆØ×'Ñ'×+Ñ+¨CÓ0Ó0ÜÐ9Ó:Ð:ØÒØ�K‰K˜ÔØ× Ñ  Ò%ñ r   c                óä   € V P                   '       d$   \        P                  ! R V P                   24        VP	                  4        R#   \
         d    \        P                  ! RR4        R# i ; i)zadbapi closing: NzConnection close failed)r)   r   r*   rR   r   r&   r'   r˜   s   &&r   r–   ÚConnectionPool._close¯  sP   € Ø�:�:ˆ:Ü�GŠGÐ& t§~¡~Ð&6Ð7Ô8ð	5Ø�J‰JŽLøÜô 	5Ü�GŠG�DÐ3×4ð	5ús   ·A	 Á	"A/Á.A/c                ó6  € V P                  V 4      pV P                  W4      p V! V.VO5/ VB pVP                  4        VP                  4        V#   \         d<     TP                  4        h   \         d    \        P                  ! R R4        h i ; ii ; ir}   )r~   ÚtransactionFactoryr   r%   r&   r!   r   r'   )r   r„   rx   ry   r   Útransr€   s   &&*,   r   rƒ   ÚConnectionPool._runInteraction·  s—   € Ø×%Ñ% dÓ+ˆØ×'Ñ'¨Ó3ˆð
	Ù  Ð4¨Ò4°Ñ4ˆFØ�K‰KŒMØ�K‰KŒMØˆMøÜô 	ð1Ø—‘”ð øô !ô 1Ü—’˜Ð/Õ0Øð1úð	ús/   ¤-A ÁBÁA/Á.BÁ/"BÂBÂBÂBc                óF   € VP                   ! V/ VB  VP                  4       # r   )r#   Úfetchall©r   r¦   rx   ry   s   &&*,r   rˆ   ÚConnectionPool._runQueryÆ  s    € Ø�Š�tÐ"˜rÒ"Ø�~‰~ÓÐr   c                ó*   € VP                   ! V/ VB  R # r   )r#   rª   s   &&*,r   r�   ÚConnectionPool._runOperationÊ  s   € Ø�Š�tÐ"˜rÔ"r   c                óÆ   € R V P                   RV P                  RV P                  RV P                  RV P                  RV P
                  RV P                  RV P                  /# ©rR   r\   r]   r)   r   r$   rX   rY   r¯   r   s   &r   Ú__getstate__ÚConnectionPool.__getstate__Í  sT   € à˜Ÿ™Ø�4—8‘8Ø�4—8‘8Ø�T—Z‘ZØ˜Ÿ™Ø˜Ÿ™Ø˜Ÿ™Ø�d—k‘kð	
ð 		
r   c                óz   € Wn         V P                  ! V P                  .V P                  O5/ V P                  B  R # r   )Ú__dict__r   rR   rX   rY   )r   Ústates   &&r   Ú__setstate__ÚConnectionPool.__setstate__Ù  s)   € ØŒØ�Š�d—n‘nÐD t§}¡}ÒD¸¿¹ÔDr   )r³   rW   rX   r^   rY   rT   rR   r]   r\   ro   rr   re   ra   rQ   )(r   r	   r
   r   r   ÚsplitrZ   r)   r\   r]   r3   rœ   r   r$   ro   r   r~   r:   r¥   rr   r   rd   rj   rz   rv   r…   rŠ   rŽ   r   rq   r.   r(   r–   rƒ   rˆ   r�   r°   rµ   r   r6   r7   s   @r   rI   rI   ~   s¼   ø‡ € ñð& >×CÑCÓE€Gà€EØ
€CØ
€CØ€DØ€GØ€IØ€Hà€GØ"ÐØ$Ðð €JòEBòNò ò
ò4ò#
òJ@ò(Dò*
ò	!òò.&ò5òò ò#ò

÷Eð Er   rI   N)r   rV   r   r_   r   r   r    r   r   r:   rI   Ú__all__r   r   r   Ú<module>r¹      sP   ðñ
õ %ß 'ô�Yô ÷4/ñ 4/÷n.+ñ .+÷b]Eñ ]Eð@ Ð*Ð
+‚r   