Server IP : 85.214.239.14 / Your IP : 3.143.237.203 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 : /proc/3/task/3/cwd/srv/modoboa/env/lib64/python3.5/site-packages/gevent/tests/ |
Upload File : |
import gevent import gevent.testing as greentest from gevent.testing.six import xrange class appender(object): def __init__(self, lst, item): self.lst = lst self.item = item def __call__(self, *args): self.lst.append(self.item) class Test(greentest.TestCase): count = 2 def test_greenlet_link(self): lst = [] # test that links are executed in the same order as they were added g = gevent.spawn(lst.append, 0) for i in xrange(1, self.count): g.link(appender(lst, i)) g.join() self.assertEqual(lst, list(range(self.count))) class Test3(Test): count = 3 class Test4(Test): count = 4 class TestM(Test): count = 1000 class TestSleep0(greentest.TestCase): def test(self): lst = [] gevent.spawn(sleep0, lst, '1') gevent.spawn(sleep0, lst, '2') gevent.wait() self.assertEqual(' '.join(lst), '1A 2A 1B 2B') def sleep0(lst, param): lst.append(param + 'A') gevent.sleep(0) lst.append(param + 'B') if __name__ == '__main__': greentest.main()