| Server IP : 85.214.239.14 / Your IP : 216.73.216.178 Web Server : Apache/2.4.65 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 8.2.29 Disable Function : NONE MySQL : OFF | cURL : ON | 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()