/opt/cloudlinux/venv/lib/python3.11/site-packages/smmap/__pycache__
Edit: /opt/cloudlinux/venv/lib/python3.11/site-packages/smmap/__pycache__/mman.cpython-311.pyc (26833B)
§
¦U§-ð4ã óŽ — d Z ddlmZmZmZmZ ddlZddlmZ g d¢Z G d„ d¦ « Z
G d „ d
¦ « Z G d„ de¦ « ZdS )
zlModule containing a memory memory manager which provides a sliding window on a number of memory mapped filesé )Ú MapWindowÚ MapRegionÚ
MapRegionListÚ is_64_bité N)Úreduce)ÚStaticWindowMapManagerÚSlidingWindowMapManagerÚWindowCursorc ó¤ — e Zd ZdZdZdd„Zd„ Zd„ Zd„ Zd„ Z d „ Z
d
„ Zd„ Zdd
„Z
d„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ ZdS )r aã
Pointer into the mapped region of the memory manager, keeping the map
alive until it is destroyed and no other client uses it.
Cursors should not be created manually, but are instead returned by the SlidingWindowMapManager
**Note:**: The current implementation is suited for static and sliding window managers, but it also means
that it must be suited for the somewhat quite different sliding manager. It could be improved, but
I see no real need to do so.©Ú_managerÚ_rlistÚ_regionÚ_ofsÚ_sizeNc óL — || _ || _ d | _ d| _ d| _ d S )Nr r
)ÚselfÚmanagerÚregionss ú\/builddir/build/BUILD/cloudlinux-venv-1.0.12/venv/lib/python3.11/site-packages/smmap/mman.pyÚ__init__zWindowCursor.__init__% s) € ؈Œ
؈ŒØˆŒØˆŒ ؈Œ
ˆ
ˆ
ó c ó. — | ¦ « d S ©N©Ú_destroy©r s r Ú__del__zWindowCursor.__del__, ó € Ø�
Š
‰Œˆˆˆr c ó — | S r © r s r Ú __enter__zWindowCursor.__enter__/ s € ؈r c ó. — | ¦ « d S r r )r Úexc_typeÚ exc_valueÚ tracebacks r Ú__exit__zWindowCursor.__exit__2 r r c ó — | ¦ « | j �k t | j ¦ « dk r8| j j | j ¦ « ¦ « dS dS # t t f$ r Y dS w xY wdS )z&Destruction code to decrement countersNr ) Úunuse_regionr Úlenr Ú_fdictÚpopÚ
path_or_fdÚ TypeErrorÚKeyErrorr s r r zWindowCursor._destroy5 sž € à×ÒÑÔÐàŒ;Ð"ð
Ý�t”{Ñ#Ô# qÒ(Ð(à”MÔ(×,Ò,¨T¬[×-CÒ-CÑ-EÔ-EÑFÔFÐFÐFÐFð )Ð(øõ �xÐ(ð
ð
ð
ð
��ð
øøøð #Ð"s �AA/ Á/BÂBc ó4 — |j | _ t |j ¦ « |j ¦ « | _ |j | _ |j | _ |j | _ | j D ]}| ¦ « Œ| j �| j ¦ « dS dS )z>Copy all data from rhs into this instance, handles usage countN)r Útyper r r r Úincrement_client_count)r ÚrhsÚregions r Ú
_copy_fromzWindowCursor._copy_fromJ s“ € àœˆŒ
Ø&•d˜3œ:Ñ&Ô& s¤zÑ2Ô2ˆŒØ”{ˆŒØ”HˆŒ Ø”YˆŒ
à”kð ,ð ,ˆFØ×)Ò)Ñ+Ô+Ð+Ð+àŒ<Ð#ØŒL×/Ò/Ñ1Ô1Ð1Ð1Ð1ð $Ð#r c ó^ — t | ¦ « ¦ « }| | ¦ « |S )zcopy module interface)r2 r6 )r Úcpys r Ú__copy__zWindowCursor.__copy__Y s* € à�d�4‰jŒj‰lŒlˆØ�Š�tÑÔÐØˆ
r c óX — | ¦ « | |¦ « dS )z˜Assign rhs to this instance. This is required in order to get a real copy.
Alternativly, you can copy an existing instance using the copy moduleN)r r6 )r r4 s r ÚassignzWindowCursor.assign` s) € ð
�
Š
‰ŒˆØ�Š˜ÑÔÐÐÐr r c ó — d}| j }| j ¦ « }t |p|| ¦ « p|¦ « }| j �1| j |¦ « rd}n| ¦ « ||k r| S |r<| | j |||d¦ « | _ | j ¦ « || j j
z
| _ t || j ¦ « |z
¦ « | _
| S )a$ Assure we point to a window which allows access to the given offset into the file
:param offset: absolute offset in bytes into the file
:param size: amount of bytes to map. If 0, all available bytes will be mapped
:param flags: additional flags to be given to os.open in case a file handle is initially opened
for mapping. Has no effect if a region can actually be reused.
:return: this instance - it should be queried for whether it points to a valid memory region.
This is not the case if the mapping failed because we reached the end of the file
**Note:**: The size actually mapped may be smaller than the given size. If that is the case,
either the file has reached its end, or the map was created between two existing regionsTNF)r r Ú file_sizeÚminÚwindow_sizer Úincludes_ofsr* Ú_obtain_regionr3 Ú_br Úofs_endr )r ÚoffsetÚsizeÚflagsÚneed_regionÚmanÚfsizes r Ú
use_regionzWindowCursor.use_regionf s € ð ˆØŒmˆØ”×%Ò%Ñ'Ô'ˆÝ�4�=˜5 #§/¢/Ñ"3Ô"3Ð"<°uÑ=Ô=ˆàŒ<Ð#ØŒ|×(Ò(¨Ñ0Ô0ð
$Ø#��à×!Ò!Ñ#Ô#Ð#ð
�UŠ?ˆ?؈Kð ð 2Ø×-Ò-¨d¬k¸6À4ÈÐPUÑVÔVˆDŒLØŒL×/Ò/Ñ1Ô1Ð1ð ˜Tœ\œ_Ñ,ˆŒ ݘ˜tœ|×3Ò3Ñ5Ô5¸Ñ>Ñ?Ô?ˆŒ
àˆr c óV — | j �| j d¦ « d| _ dS )a/ Unuse the current region. Does nothing if we have no current region
**Note:** the cursor unuses the region automatically upon destruction. It is recommended
to un-use the region once you are done reading from it in persistent cursors as it
helps to free up resource more quicklyNéÿÿÿÿ)r r3 r s r r* zWindowCursor.unuse_regionŽ s- € ð Œ<Ð#ØŒL×/Ò/°Ñ3Ô3Ð3؈Œˆˆr c ó‚ — t | j ¦ « ¦ « | j | j | j z … S )aÊ Return a buffer object which allows access to our memory region from our offset
to the window size. Please note that it might be smaller than you requested when calling use_region()
**Note:** You can only obtain a buffer if this instance is_valid() !
**Note:** buffers should not be cached passed the duration of your access as it will
prevent resources from being freed even though they might not be accounted for anymore !)Ú
memoryviewr Úbufferr r r s r rO zWindowCursor.bufferš s5 € õ ˜$œ,×-Ò-Ñ/Ô/Ñ0Ô0°´¸4¼9ÀTÄZÑ;OÐ1OÔPÐPr c ó4 — | j ¦ « S )a
:return: the underlying raw memory map. Please not that the offset and size is likely to be different
to what you set as offset and size. Use it only if you are sure about the region it maps, which is the whole
file in case of StaticWindowMapManager)r Úmapr s r rQ zWindowCursor.map¤ s € ð
Œ|×ÒÑ!Ô!Ð!r c ó — | j duS )z2:return: True if we have a valid and usable regionN©r r s r Úis_validzWindowCursor.is_valid« s € àŒ| 4Ð'Ð'r c ó — | j duS )z?:return: True if we are associated with a specific file alreadyN)r r s r Ú
is_associatedzWindowCursor.is_associated¯ s € àŒ{ $Ð&Ð&r c ó* — | j j | j z S )zh:return: offset to the first byte pointed to by our cursor
**Note:** only if is_valid() is True)r rB r r s r Ú ofs_beginzWindowCursor.ofs_begin³ s € ð Œ|Œ ¤Ñ*Ð*r c ó: — | j j | j z | j z S )z3:return: offset to one past the last available byte©r rB r r r s r rC zWindowCursor.ofs_end¹ s € ð Œ|Œ ¤Ñ*¨T¬ZÑ7Ð7r c ó — | j S )z$:return: amount of bytes we point to)r r s r rE zWindowCursor.size¾ s
€ àŒzÐr c ó — | j S )z›:return: our mapped region, or None if nothing is mapped yet
:raise AssertionError: if we have no current region. This is only useful for debuggingrS r s r r5 zWindowCursor.region s € ð Œ|Ðr c óz — | j j | j z |cxk o| j j | j z | j z k nc S )zš:return: True if the given absolute offset is contained in the cursors
current region
**Note:** cursor must be valid for this to workrZ )r Úofss r r@ zWindowCursor.includes_ofsÇ sE € ð ”” $¤)Ñ+°Ð`Ð`Ò`Ð`°t´|´ÈÌÑ7RÐUYÔU_Ñ7_Ò`Ð`Ð`Ð`Ð`r c ó4 — | j ¦ « S )z$:return: size of the underlying file)r r= r s r r= zWindowCursor.file_sizeÏ s € àŒ{×$Ò$Ñ&Ô&Ð&r c ó4 — | j ¦ « S )z>:return: path or file descriptor of the underlying mapped file)r r. r s r r. zWindowCursor.path_or_fdÓ s € àŒ{×%Ò%Ñ'Ô'Ð'r c óª — t | j ¦ « t ¦ « rt d¦ « ‚| j ¦ « S )ze:return: path of the underlying mapped file
:raise ValueError: if attached path is not a pathz>Path queried although mapping was applied to a file descriptor)Ú
isinstancer r. ÚintÚ
ValueErrorr s r ÚpathzWindowCursor.path× sH € õ �d”k×,Ò,Ñ.Ô.µÑ4Ô4ð _ÝÐ]Ñ^Ô^Ð^àŒ{×%Ò%Ñ'Ô'Ð'r c óª — t | j ¦ « t ¦ « rt d¦ « ‚| j ¦ « S )zÈ:return: file descriptor used to create the underlying mapping.
**Note:** it is not required to be valid anymore
:raise ValueError: if the mapping was not created by a file descriptorz@File descriptor queried although mapping was generated from path)rb r r. Ústrrd r s r ÚfdzWindowCursor.fdß sH € õ
�d”k×,Ò,Ñ.Ô.µÑ4Ô4ð aÝÐ_Ñ`Ô`Ð`àŒ{×%Ò%Ñ'Ô'Ð'r )NN)r r r )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú __slots__r r r# r( r r6 r9 r; rJ r* rO rQ rT rV rX rC rE r5 r@ r= r. re rh r" r r r r s� € € € € € ð$ð $ð€Iðð ð ð ðð ð ðð ð ðð ð ðð ð ð*2ð 2ð 2ðð ð ðð ð ð&ð &ð &ð &ðPð ð ðQð Qð Qð"ð "ð "ð(ð (ð (ð'ð 'ð 'ð+ð +ð +ð8ð 8ð 8ð
ð ð ðð ð ð
að að að'ð 'ð 'ð(ð (ð (ð(ð (ð (ð(ð (ð (ð (ð (r r c óˆ — e Zd ZdZg d¢ZeZeZe Z
eZdZ
ddej fd„Zd„ Zd„ Zd„ Zd „ Zd
„ Zd„ Zd„ Zd
„ Zd„ Zd„ Zd„ ZdS )r aß Provides a manager which will produce single size cursors that are allowed
to always map the whole file.
Clients must be written to specifically know that they are accessing their data
through a StaticWindowMapManager, as they otherwise have to deal with their window size.
These clients would have to use a SlidingWindowMapBuffer to hide this fact.
This type will always use a maximum window size, and optimize certain methods to
accommodate this fact)r, Ú_window_sizeÚ_max_memory_sizeÚ_max_handle_countÚ_memory_sizeÚ
_handle_counti r c ó — t ¦ « | _ || _ || _ || _ d| _ d| _ |dk r!d}t ¦ « rd}|| j z | _ |dk r#d}t ¦ « rd}|| j z | _ dS dS )a£ initialize the manager with the given parameters.
:param window_size: if -1, a default window size will be chosen depending on
the operating system's architecture. It will internally be quantified to a multiple of the page size
If 0, the window may have any size, which basically results in mapping the whole file at one
:param max_memory_size: maximum amount of memory we may map at once before releasing mapped regions.
If 0, a viable default will be set depending on the system's architecture.
It is a soft limit that is tried to be kept, but nothing bad happens if we have to over-allocate
:param max_open_handles: if not maxint, limit the amount of open file handles to the given number.
Otherwise the amount is only limited by the system itself. If a system or soft limit is hit,
the manager will free as many handles as possibler é@ i i N) Údictr, ro rp rq rr rs r Ú_MB_in_bytes)r r? Úmax_memory_sizeÚmax_open_handlesÚcoeffs r r zStaticWindowMapManager.__init__ s§ € õ ‘f”fˆŒØ'ˆÔØ /ˆÔØ!1ˆÔØˆÔØˆÔà˜Š?ˆ?؈E݉{Œ{ð
Ø�à %¨Ô(9Ñ 9ˆDÔð ˜aÒÐØˆE݉{Œ{ð
Ø�à$)¨DÔ,=Ñ$=ˆDÔ!Ð!Ð!ð Ðr c óÞ — d}|dk s| j |z | j k rÑd}d}| j ¦ « D ]5}|D ]0}| ¦ « dk r|�|j |j k r|}|}Œ1Œ6|€n{|dz
}|| |¦ « = | d¦ « | xj | ¦ « z c_ | xj dz c_ |dk °¾| j |z | j k °Ñ|S )am Unmap the region which was least-recently used and has no client
:param size: size of the region we want to map next (assuming its not already mapped partially or full
if 0, we try to free any available region
:return: Amount of freed regions
.. Note::
We don't raise exceptions anymore, in order to keep the system working, allowing temporary overallocation.
If the system runs out of memory, it will tell.
.. TODO::
implement a case where all unusued regions are discarded efficiently.
Currently its only brute force
r Nr rL )
rr rp r, ÚvaluesÚclient_countÚ_ucÚindexr3 rE rs )r rE Ú num_foundÚ
lru_regionÚlru_listr r5 s r Ú_collect_lru_regionz*StaticWindowMapManager._collect_lru_region/ s0 € ð ˆ Ø�qŠyˆy˜dÔ/°$Ñ6¸Ô9NÒNÐN؈J؈HØœ;×-Ò-Ñ/Ô/ð
+ð
+�Ø%ð +ð +�Fà×+Ò+Ñ-Ô-°Ò2Ð2Ø'Ð/°6´:À
ÄÒ3NÐ3NØ%+˜
Ø#*˜øð+ð Ð!Øð
˜‰NˆIؘŸš¨
Ñ3Ô3Ð4Ø×-Ò-¨bÑ1Ô1Ð1ØÐÔ §¢Ñ!2Ô!2Ñ2ÐÔØÐÔ !Ñ#ÐÔð- �qŠyˆy˜dÔ/°$Ñ6¸Ô9NÒNÐNð0 Ðr c óD — | j |z | j k r| |¦ « d}|rt |¦ « dk sJ ‚|d }n¾ | | ¦ « dt j |¦ « }nA# t $ r4 |r‚ | d¦ « | ||||d¦ « cY S w xY w| xj
dz
c_
| xj | ¦ « z
c_ | |¦ « |
|¦ « sJ ‚|S )z·Utilty to create a new region - for more information on the parameters,
see MapCursor.use_region.
:param a: A regions (a)rray
:return: The newly created regionNr r T)rr rp rƒ r+ ÚMapRegionClsr. ÚsysÚmaxsizeÚ ExceptionrA rs rE Úappendr@ )r ÚarD rE rF Úis_recursiveÚrs r rA z%StaticWindowMapManager._obtain_regionX sJ € ð
Ô˜tÑ# dÔ&;Ò;Ð;Ø×$Ò$ TÑ*Ô*Ð*ð
ˆØð Ý�q‘6”6˜Q’;�;�;�;Ø�!”ˆAˆAð
IØ×%Ò% a§l¢l¡n¤n°a½¼ÀeÑLÔL��øÝð
Ið
Ið
Ið
ð ð à×(Ò(¨Ñ+Ô+Ð+Ø×*Ò*¨1¨f°d¸EÀ4ÑHÔHÐHÐHÐHð
Iøøøð
ÐÔ !Ñ#ÐÔØÐÔ §¢¡¤Ñ)ÐÔØ
�HŠH�Q‰KŒKˆKð �~Š~˜fÑ%Ô%Ð%Ð%Ð%؈s Á4B Â;B?Â>B?c ó¤ — | j |¦ « }|€| |¦ « }|| j |<