/usr/lib/python2.6/site-packages/swiftclient
NameSizeModeActions
client.py633230644editdlrm
client.pyc549830644editdlrm
command_helpers.py66150644editdlrm
command_helpers.pyc66920644editdlrm
exceptions.py24640644editdlrm
exceptions.pyc18220644editdlrm
multithreading.py75690644editdlrm
multithreading.pyc90710644editdlrm
service.py895930644editdlrm
service.pyc579250644editdlrm
shell.py629740755editdlrm
shell.pyc495480644editdlrm
utils.py74360644editdlrm
utils.pyc92340644editdlrm
version.py12870644editdlrm
version.pyc4620644editdlrm
__init__.py10730644editdlrm
__init__.pyc4060644editdlrm
Edit: /usr/lib/python2.6/site-packages/swiftclient/multithreading.pyc (9071B)
Ñò ;vVc@sŽddklZddkZddkZddklZddklZdefd„ƒYZ defd„ƒYZ d efd „ƒYZ dS( iÿÿÿÿ(tprint_functionN(tThreadPoolExecutor(t PriorityQueuet OutputManagercBs’eZdZdZddd„Zd„Zd„Zd„Zd„Z d„Z ee d„Z d „Z d „Zdd „Zd d „Zd„ZRS(s One object to manage and provide helper functions for output. This object is a context manager and returns itself into the context. When entering the context, two printing threads are created (see below) and they are waited on and cleaned up when exiting the context. Also, thread-safe printing to two streams is provided. The :meth:`print_msg` method will print to the supplied ``print_stream`` (defaults to ``sys.stdout``) and the :meth:`error` method will print to the supplied ``error_stream`` (defaults to ``sys.stderr``). Both of these printing methods will format the given string with any supplied ``*args`` (a la printf). On Python 2, Unicode messages are encoded to utf8. The attribute :attr:`self.error_count` is incremented once per error message printed, so an application can tell if any worker threads encountered exceptions or otherwise called :meth:`error` on this instance. The swift command-line tool uses this to exit non-zero if any error strings were printed. icCsW|pti|_tddƒ|_|pti|_tddƒ|_d|_dS(s5 :param print_stream: The stream to which :meth:`print_msg` sends formatted messages. :param error_stream: The stream to which :meth:`error` sends formatted messages. On Python 2, Unicode messages are encoded to utf8. t max_workersiiN( tsyststdoutt print_streamRt print_pooltstderrt error_streamterror_print_poolt error_count(tselfRR ((sF/tmp/pip-build-cD3xZi/python-swiftclient/swiftclient/multithreading.pyt__init__0s cCs|S(N((R ((sF/tmp/pip-build-cD3xZi/python-swiftclient/swiftclient/multithreading.pyt __enter__@scCs0|ii|||ƒ|ii|||ƒdS(N(R t__exit__R(R texc_typet exc_valuet traceback((sF/tmp/pip-build-cD3xZi/python-swiftclient/swiftclient/multithreading.pyRCscCs |ii|i||iƒdS(N(Rtsubmitt_writeR(R tdata((sF/tmp/pip-build-cD3xZi/python-swiftclient/swiftclient/multithreading.pyt print_rawGscCsQtio|ii|ƒ|iƒntio|i|ƒ|iƒndS(N(tsixtPY3tbuffertwritetflushtPY2(R Rtstream((sF/tmp/pip-build-cD3xZi/python-swiftclient/swiftclient/multithreading.pyRJs    cGs/|o||}n|ii|i|ƒdS(N(RRt_print(R tmsgtfmt_args((sF/tmp/pip-build-cD3xZi/python-swiftclient/swiftclient/multithreading.pyt print_msgRscCsXd|}xG|D]?\}}|o| oqn|i|||fiƒƒqWdS(Ns %%%ds: %%s(R"trstrip(R titemstoffsett skip_missingttemplatetktv((sF/tmp/pip-build-cD3xZi/python-swiftclient/swiftclient/multithreading.pyt print_itemsWs   cGs/|o||}n|ii|i|ƒdS(N(R Rt _print_error(R R R!((sF/tmp/pip-build-cD3xZi/python-swiftclient/swiftclient/multithreading.pyterror^scCs|iS(N(R (R ((sF/tmp/pip-build-cD3xZi/python-swiftclient/swiftclient/multithreading.pytget_error_countcscCs^|djo |i}ntio&t|tiƒo|idƒ}nt|d|ƒdS(Ntutf8tfile(tNoneRRRt isinstancet text_typetencodetprint(R titemR((sF/tmp/pip-build-cD3xZi/python-swiftclient/swiftclient/multithreading.pyRfs   icCs%|i|7_|i|d|iƒS(NR(R RR (R R5tcount((sF/tmp/pip-build-cD3xZi/python-swiftclient/swiftclient/multithreading.pyR+mscGs5|o||}n|ii|i|ddƒdS(NR6i(R RR+(R R R!((sF/tmp/pip-build-cD3xZi/python-swiftclient/swiftclient/multithreading.pytwarningqsN(t__name__t __module__t__doc__tDEFAULT_OFFSETR0RRRRRR"tFalseR*R,R-RR+R7(((sF/tmp/pip-build-cD3xZi/python-swiftclient/swiftclient/multithreading.pyRs         tMultiThreadingManagercBs5eZdZddddd„Zd„Zd„ZRS(sŒ One object to manage context for multi-threading. This should make bin/swift less error-prone and allow us to test this code. i cCsXt|d|ƒ|_t|d|ƒ|_t|d|ƒ|_t|d|ƒ|_dS(s  :param segment_threads: The number of threads allocated to segment uploads :param object_dd_threads: The number of threads allocated to object download/delete jobs :param object_uu_threads: The number of threads allocated to object upload/update based jobs :param container_threads: The number of threads allocated to container/account level jobs RN(tConnectionThreadPoolExecutort segment_pooltobject_dd_pooltobject_uu_pooltcontainer_pool(R tcreate_connectiontsegment_threadstobject_dd_threadstobject_uu_threadstcontainer_threads((sF/tmp/pip-build-cD3xZi/python-swiftclient/swiftclient/multithreading.pyR~scCs|S(N((R ((sF/tmp/pip-build-cD3xZi/python-swiftclient/swiftclient/multithreading.pyR•scCs\|ii|||ƒ|ii|||ƒ|ii|||ƒ|ii|||ƒdS(N(R?RR@RARB(R RRR((sF/tmp/pip-build-cD3xZi/python-swiftclient/swiftclient/multithreading.pyR˜s(R8R9R:RRR(((sF/tmp/pip-build-cD3xZi/python-swiftclient/swiftclient/multithreading.pyR=xs   R>cBs eZdZd„Zd„ZRS(s A wrapper class to maintain a pool of connections alongside the thread pool. We start by creating a priority queue of connections, and each job submitted takes one of those connections (initialising if necessary) and passes it as the first arg to the executed function. At the end of execution that connection is returned to the queue. By using a PriorityQueue we avoid creating more connections than required. We will only create as many connections as are required concurrently. cCs_tƒ|_||_x-td|ƒD]}|ii|dfƒq%Wtt|ƒi|ƒdS(Ni( Rt _connectionst_create_connectiontrangetputR0tsuperR>R(R RCRtp((sF/tmp/pip-build-cD3xZi/python-swiftclient/swiftclient/multithreading.pyR«s   cs.‡‡‡‡fd†}ttˆƒi|ƒS(Ncs‹d}d}zPˆiiƒ\}}|djoˆiƒ}n|fˆ}ˆ|ˆŽSWd|dj oˆii||fƒnXdS(N(R0RHtgetRIRK(tprioritytconnt conn_args(R targstfntkwargs(sF/tmp/pip-build-cD3xZi/python-swiftclient/swiftclient/multithreading.pytconn_fn³s   (RLR>R(R RSRRRTRU((R RRRTRSsF/tmp/pip-build-cD3xZi/python-swiftclient/swiftclient/multithreading.pyR²s(R8R9R:RR(((sF/tmp/pip-build-cD3xZi/python-swiftclient/swiftclient/multithreading.pyR>Ÿs  ( t __future__RRRtconcurrent.futuresRtsix.moves.queueRtobjectRR=R>(((sF/tmp/pip-build-cD3xZi/python-swiftclient/swiftclient/multithreading.pyts  _'