403Webshell
Server IP : 104.21.94.62  /  Your IP : 216.73.217.125
Web Server : Apache
System : Linux semi1.us.cloudlogin.co 5.10.244-xeon-hst #1 SMP Sun Sep 14 17:09:20 UTC 2025 x86_64
User : xessglobal ( 271017)
PHP Version : 8.1.33
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : ON |  Sudo : OFF |  Pkexec : ON
Directory :  /proc/self/root/usr/local/python-3.13/lib/python3.13/test/test_free_threading/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /proc/self/root/usr/local/python-3.13/lib/python3.13/test/test_free_threading/test_gc.py
import unittest

import threading
from threading import Thread
from unittest import TestCase
import gc

from test.support import threading_helper


class MyObj:
    pass


@threading_helper.requires_working_threading()
class TestGC(TestCase):
    def test_get_objects(self):
        event = threading.Event()

        def gc_thread():
            for i in range(100):
                o = gc.get_objects()
            event.set()

        def mutator_thread():
            while not event.is_set():
                o1 = MyObj()
                o2 = MyObj()
                o3 = MyObj()
                o4 = MyObj()

        gcs = [Thread(target=gc_thread)]
        mutators = [Thread(target=mutator_thread) for _ in range(4)]
        with threading_helper.start_threads(gcs + mutators):
            pass

    def test_get_referrers(self):
        event = threading.Event()

        obj = MyObj()

        def gc_thread():
            for i in range(100):
                o = gc.get_referrers(obj)
            event.set()

        def mutator_thread():
            while not event.is_set():
                d1 = { "key": obj }
                d2 = { "key": obj }
                d3 = { "key": obj }
                d4 = { "key": obj }

        gcs = [Thread(target=gc_thread) for _ in range(2)]
        mutators = [Thread(target=mutator_thread) for _ in range(4)]
        with threading_helper.start_threads(gcs + mutators):
            pass


if __name__ == "__main__":
    unittest.main()

Youez - 2016 - github.com/yon3zu
LinuXploit