Server IP : 85.214.239.14 / Your IP : 18.118.208.127 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /srv/modoboa/env/lib64/python3.5/site-packages/gevent/tests/ |
Upload File : |
from gevent import monkey; monkey.patch_all() import gevent.hub # check that the locks initialized by 'threading' did not init the hub assert gevent.hub._get_hub() is None, 'monkey.patch_all() should not init hub' import gevent import gevent.testing as greentest import threading def helper(): threading.currentThread() gevent.sleep(0.2) class Test(greentest.TestCase): def _do_test(self, spawn): before = len(threading._active) g = spawn(helper) gevent.sleep(0.1) self.assertEqual(len(threading._active), before + 1) try: g.join() except AttributeError: while not g.dead: gevent.sleep() # Raw greenlet has no join(), uses a weakref to cleanup. # so the greenlet has to die. On CPython, it's enough to # simply delete our reference. del g # On PyPy, it might take a GC, but for some reason, even # running several GC's doesn't clean it up under 5.6.0. # So we skip the test. #import gc #gc.collect() self.assertEqual(len(threading._active), before) def test_cleanup_gevent(self): self._do_test(gevent.spawn) @greentest.skipOnPyPy("weakref is not cleaned up in a timely fashion") def test_cleanup_raw(self): self._do_test(gevent.spawn_raw) if __name__ == '__main__': greentest.main()