File manager - Edit - /opt/imh-python/lib/python2.7/site-packages/rads/context.pyo
Back
� �]c @ s� d Z d d l Z d d l Z d d l m Z d d l m Z d d l Z y d d l Z e Z Wn e k ry e Z n Xd d l Z e e e d � � Z e d d � � Z e d d d d � � Z e e g Z d S( sx Context Managers for RADS. Context managers modify the behavior of an indented block of code in some way by silently calling __enter__() and __exit__() when you change indentation. __exit__() will always be called, even if the indented code raised an exception. For example in fabric, settings is a context manager: def function_name(): with settings(warn_only=True): run('some_command') This part of RADS is very closely tied to rads.decorators. Python 3.2 introduces contextlib.ContextDecorator which allows something to behave as both a decorator and a context manager. Older versions of python need to implement this manually. rads.implementation.contextdecorator works around that. Decorators modify the behavior of an entire function. For example in fabric, with_settings is a decorator: @with_settings(warn_only=True) def function_name(): run('some_command') i����N( t contextmanager( t S_LockErrorc o s� t s t d � � n t j | | � } | r= | j t � n | j � } z | r` | | f Vn | VWd | j � | j � Xd S( s� Yield a database cursor as a context manager. Args are the same as with MySQLdb.connect, except for: _autocommit(default False) whether to set autocommit _yield_conn(default False) whether to yield conn, cur isntead of just curs! imh-python-mysql is not installedN( t MYSQLDBt ImportErrort MySQLdbt connectt autocommitt Truet cursort close( t _autocommitt _yield_connt argst kwargst connt cur( ( s; /opt/imh-python/lib/python2.7/site-packages/rads/context.pyt db_cur( s c c s� | d k r t j } n t j t j t j � } y$ | j d t j | � j � � Wn t j k rp t � n Xz d VWd | j � Xd S( sN Create an abstract UNIX socket which will behave as a "lock" or raise socket.error if the "lock" already existed. This can be used en lieu of /var/run file pids/locks to determine if an instance of said process is already running. This method ensures no file locks are left behind if the process terminates prematurelyt %sN( t Nonet main_objt __file__t sockett AF_UNIXt SOCK_DGRAMt bindt hashlibt sha256t hexdigestt errorR R ( t namet lock_socket( ( s; /opt/imh-python/lib/python2.7/site-packages/rads/context.pyt s_lock= s $ g �?c c s� | d k r t j } n d } xs t r� y t | � � d Vd SWd QXWq! t k r� t j | � | | 7} | d k r� | | k r� � q� q! Xq! Wd S( Ng ( R R R R R R t timet sleep( R R! t max_sleept slept( ( s; /opt/imh-python/lib/python2.7/site-packages/rads/context.pyt wait_lockQ s ( t __doc__t __main__R R t$ rads.implementation.contextdecoratorR t rads.exceptionsR R R R R R t FalseR R R R R$ t __rads_context_managers__( ( ( s; /opt/imh-python/lib/python2.7/site-packages/rads/context.pyt <module> s$
| ver. 1.4 |
Github
|
.
| PHP 8.3.31 | Generation time: 0 |
proxy
|
phpinfo
|
Settings