mfyddlZddlZddlmZmZddlmZddlmZmZddl m Z ddl m Z e rddl mZddl mZdd l mZeZGd d eZdS) N)sleeptime)check_thread_support)QueueFull)logger)MYPY)Any)Optional)Callablec^eZdZd dZedZdZdZdZdZ dd Z d Z d Z d Z dS)BackgroundWorkerctt||_tj|_d|_d|_dSN)rr_queue threadingLock_lock_thread_thread_for_pid)self queue_sizes H/opt/imunify360/venv/lib64/python3.11/site-packages/sentry_sdk/worker.py__init__zBackgroundWorker.__init__sAJ'' ^%%  #c|jtjkrdS|jsdS|jS)NF)rosgetpidris_alivers rr zBackgroundWorker.is_alives@  29;; . .5| 5|$$&&&rc@|js|dSdSr)r startr!s r_ensure_threadzBackgroundWorker._ensure_thread&s'}  JJLLLLL  rct|z}|j}|j |jrU|tz }|dkr |jdS|j||jU |jdS#|jwxYw)NrF)timeoutT)rrall_tasks_doneacquireunfinished_tasksreleasewait)rr&deadlinequeuedelays r_timed_queue_joinz"BackgroundWorker._timed_queue_join+s66G#  $$&&& +( 9 466)A::  ( ( * * * * * $))%)888 ( 9   ( ( * * * * *E ( ( * * * *sB+-"B++Cc*|j5|jsktj|jd|_|jd|jtj |_ ddddS#1swxYwYdS)Nzraven-sentry.BackgroundWorker)targetnameT) rr rThread_targetr setDaemonr#rrrr!s rr#zBackgroundWorker.start=s Z 3 3= 3(/<.M     &&t,,, ""$$$')y{{$ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3sA3BB B c"tjd|j5|jrS |jt n$#t$rtjdYnwxYwd|_d|_ddddS#1swxYwYdS)z Kill worker thread. Returns immediately. Not useful for waiting on shutdown for events, use `flush` for that. z"background worker got kill requestz)background worker queue full, kill failedN) rdebugrrr put_nowait _TERMINATORrrr!s rkillzBackgroundWorker.killHs  9::: Z , ,| ,NK**;7777NNNL!LMMMMMN $ '+$ , , , , , , , , , , , , , , , , , ,s4BABA&#B%A&&BB BNctjd|j5|jr|dkr|||dddn #1swxYwYtjddS)Nz#background worker got flush requestgzbackground worker flushed)rr7rr _wait_flush)rr&callbacks rflushzBackgroundWorker.flushYs :;;; Z 4 4} 43  (333 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4  011111s$A  AActd|}||sV|j}t jd|| ||||||z dSdS)Ng?z%d event(s) pending on flush)minr/rqsizerr7)rr&r=initial_timeoutpendings rr<zBackgroundWorker._wait_flushasc7++%%o66 >k''))G L7 A A A#'***  " "7_#< = = = = =  > >rc| |j|dS#t$rt jdYdSwxYw)Nz,background worker queue full, dropping event)r$rr8rrr7rr=s rsubmitzBackgroundWorker.submitkso  I K " "8 , , , , , I I I LG H H H H H H Is2AAcv |j} |tur |jdS |n&#t$rt jddYnwxYw|jn#|jwxYwtd)NTzFailed processing job)exc_infor)rgetr9 task_done ExceptionrerrorrrEs rr4zBackgroundWorker._targetss {((H ({**  %%''''' IHJJJJ IIIL!84HHHHHHI %%'''' %%'''' !HHH s/ B  A B A0-B /A00B B()rr)__name__ __module__ __qualname__rpropertyr r$r/r#r:r>r<rFr4rrrrs$$$$''X' +++$ 3 3 3,,,"2222>>>III     rr)rrrrsentry_sdk._compatrsentry_sdk._queuerrsentry_sdk.utilsrsentry_sdk._typesr typingr r r objectr9rrQrrrXs  333333))))))))######"""""" fhh lllllvlllllr