├── .gitignore ├── .pep8 ├── .travis.yml ├── AUTHORS ├── LICENSE ├── MANIFEST.in ├── Makefile ├── README.rst ├── TODO ├── benchmarks ├── micro.sh ├── micro_greenlet_link.sh ├── micro_run_callback.sh ├── micro_semaphore.sh └── micro_sleep.sh ├── c-ares ├── AUTHORS ├── CHANGELOG.git ├── CHANGES ├── CHANGES.0 ├── README ├── README.cares ├── RELEASE-NOTES ├── TODO ├── ares.h ├── ares__close_sockets.c ├── ares__get_hostent.c ├── ares__read_line.c ├── ares__timeval.c ├── ares_build.h.dist ├── ares_build.h.in ├── ares_cancel.c ├── ares_config.h.in ├── ares_create_query.c ├── ares_data.c ├── ares_data.h ├── ares_destroy.c ├── ares_dns.h ├── ares_expand_name.c ├── ares_expand_string.c ├── ares_fds.c ├── ares_free_hostent.c ├── ares_free_string.c ├── ares_getenv.c ├── ares_getenv.h ├── ares_gethostbyaddr.c ├── ares_gethostbyname.c ├── ares_getnameinfo.c ├── ares_getopt.c ├── ares_getopt.h ├── ares_getsock.c ├── ares_init.c ├── ares_iphlpapi.h ├── ares_ipv6.h ├── ares_library_init.c ├── ares_library_init.h ├── ares_llist.c ├── ares_llist.h ├── ares_mkquery.c ├── ares_nowarn.c ├── ares_nowarn.h ├── ares_options.c ├── ares_parse_a_reply.c ├── ares_parse_aaaa_reply.c ├── ares_parse_mx_reply.c ├── ares_parse_naptr_reply.c ├── ares_parse_ns_reply.c ├── ares_parse_ptr_reply.c ├── ares_parse_soa_reply.c ├── ares_parse_srv_reply.c ├── ares_parse_txt_reply.c ├── ares_platform.c ├── ares_platform.h ├── ares_private.h ├── ares_process.c ├── ares_query.c ├── ares_rules.h ├── ares_search.c ├── ares_send.c ├── ares_setup.h ├── ares_strcasecmp.c ├── ares_strcasecmp.h ├── ares_strdup.c ├── ares_strdup.h ├── ares_strerror.c ├── ares_timeout.c ├── ares_version.c ├── ares_version.h ├── ares_writev.c ├── ares_writev.h ├── bitncmp.c ├── bitncmp.h ├── config-win32.h ├── config.guess ├── config.sub ├── configure ├── get_ver.awk ├── gitinfo ├── inet_net_pton.c ├── inet_net_pton.h ├── inet_ntop.c ├── inet_ntop.h ├── install-sh ├── missing ├── nameser.h ├── setup_once.h └── windows_port.c ├── changelog.rst ├── doc ├── Makefile ├── _templates │ └── layout.html ├── community.rst ├── conf.py ├── contents.rst ├── generate_rst.py ├── gevent.core.rst ├── gevent.event.rst ├── gevent.hub.rst ├── gevent.queue.rst ├── gevent.rst ├── intro.rst ├── make.bat ├── mysphinxext.py ├── mytheme │ ├── changes │ │ ├── frameset.html │ │ ├── rstsource.html │ │ └── versionchanges.html │ ├── defindex.html │ ├── domainindex.html │ ├── genindex-single.html │ ├── genindex-split.html │ ├── genindex.html │ ├── layout.html │ ├── modindex.html │ ├── page.html │ ├── search.html │ ├── static │ │ ├── basic.css_t │ │ ├── file.png │ │ ├── img │ │ │ └── main-two-columns.gif │ │ ├── minus.png │ │ ├── omegle_48.png │ │ ├── plus.png │ │ ├── spotify_logo.png │ │ └── transparent.gif │ └── theme.conf ├── networking.rst ├── reference.rst ├── servers.rst ├── success.rst ├── synchronization.rst └── whatsnew_1_0.rst ├── examples ├── concurrent_download.py ├── dns_mass_resolve.py ├── echoserver.py ├── geventsendfile.py ├── portforwarder.py ├── processes.py ├── psycopg2_pool.py ├── server.crt ├── server.key ├── threadpool.py ├── udp_client.py ├── udp_server.py ├── unixsocket_client.py ├── unixsocket_server.py ├── webchat │ ├── README │ ├── __init__.py │ ├── application.py │ ├── chat │ │ ├── __init__.py │ │ └── views.py │ ├── manage.py │ ├── run_standalone.py │ ├── run_uwsgi │ ├── settings.py │ ├── static │ │ ├── chat.css │ │ └── chat.js │ ├── templates │ │ ├── 404.html │ │ ├── 500.html │ │ ├── index.html │ │ └── message.html │ └── urls.py ├── webproxy.py ├── webpy.py ├── wsgiserver.py └── wsgiserver_ssl.py ├── gevent ├── __init__.py ├── _fileobject2.py ├── _fileobject3.py ├── _fileobjectcommon.py ├── _semaphore.py ├── _socket2.py ├── _socket3.py ├── _socketcommon.py ├── _ssl2.py ├── _ssl3.py ├── _threading.py ├── _util.pyx ├── _util_py2.py ├── ares.pyx ├── backdoor.py ├── baseserver.py ├── callbacks.c ├── callbacks.h ├── cares.pxd ├── cares_ntop.h ├── cares_pton.h ├── core.ppyx ├── core.py ├── corecffi.py ├── coros.py ├── dnshelper.c ├── event.py ├── fileobject.py ├── greenlet.py ├── hub.py ├── libev.h ├── libev.pxd ├── libev_vfd.h ├── local.py ├── lock.py ├── monkey.py ├── os.py ├── pool.py ├── python.pxd ├── pywsgi.py ├── queue.py ├── resolver_ares.py ├── resolver_thread.py ├── select.py ├── server.py ├── socket.py ├── ssl.py ├── stathelper.c ├── subprocess.py ├── thread.py ├── threading.py ├── threadpool.py ├── timeout.py ├── util.py ├── win32util.py └── wsgi.py ├── greentest ├── 2.6 │ ├── badcert.pem │ ├── badkey.pem │ ├── https_svn_python_org_root.pem │ ├── keycert.pem │ ├── lock_tests.py │ ├── nullcert.pem │ ├── sha256.pem │ ├── test_asyncore.py │ ├── test_ftplib.py │ ├── test_httplib.py │ ├── test_httpservers.py │ ├── test_queue.py │ ├── test_select.py │ ├── test_signal.py │ ├── test_smtplib.py │ ├── test_socket.py │ ├── test_socketserver.py │ ├── test_ssl.py │ ├── test_subprocess.py │ ├── test_telnetlib.py │ ├── test_thread.py │ ├── test_threading.py │ ├── test_threading_local.py │ ├── test_timeout.py │ ├── test_urllib.py │ ├── test_urllib2.py │ ├── test_urllib2_localnet.py │ ├── test_urllib2net.py │ ├── test_wsgiref.py │ ├── version │ └── wrongcert.pem ├── 2.7 │ ├── badcert.pem │ ├── badkey.pem │ ├── https_svn_python_org_root.pem │ ├── keycert.pem │ ├── lock_tests.py │ ├── nokia.pem │ ├── nullcert.pem │ ├── sha256.pem │ ├── subprocessdata │ │ └── sigchild_ignore.py │ ├── test_asyncore.py │ ├── test_ftplib.py │ ├── test_httplib.py │ ├── test_httpservers.py │ ├── test_queue.py │ ├── test_select.py │ ├── test_signal.py │ ├── test_smtplib.py │ ├── test_socket.py │ ├── test_socketserver.py │ ├── test_ssl.py │ ├── test_subprocess.py │ ├── test_telnetlib.py │ ├── test_thread.py │ ├── test_threading.py │ ├── test_threading_local.py │ ├── test_timeout.py │ ├── test_urllib.py │ ├── test_urllib2.py │ ├── test_urllib2_localnet.py │ ├── test_urllib2net.py │ ├── test_wsgiref.py │ ├── version │ └── wrongcert.pem ├── 2.7pypy │ ├── badcert.pem │ ├── badkey.pem │ ├── https_svn_python_org_root.pem │ ├── keycert.pem │ ├── lock_tests.py │ ├── nokia.pem │ ├── nullcert.pem │ ├── sha256.pem │ ├── subprocessdata │ │ └── sigchild_ignore.py │ ├── test_asyncore.py │ ├── test_ftplib.py │ ├── test_httplib.py │ ├── test_httpservers.py │ ├── test_queue.py │ ├── test_select.py │ ├── test_signal.py │ ├── test_smtplib.py │ ├── test_socket.py │ ├── test_socketserver.py │ ├── test_ssl.py │ ├── test_subprocess.py │ ├── test_telnetlib.py │ ├── test_thread.py │ ├── test_threading.py │ ├── test_threading_local.py │ ├── test_timeout.py │ ├── test_urllib.py │ ├── test_urllib2.py │ ├── test_urllib2_localnet.py │ ├── test_urllib2net.py │ ├── test_wsgiref.py │ ├── version │ └── wrongcert.pem ├── 3.3 │ ├── badcert.pem │ ├── badkey.pem │ ├── https_svn_python_org_root.pem │ ├── keycert.pem │ ├── lock_tests.py │ ├── nokia.pem │ ├── nullcert.pem │ ├── sha256.pem │ ├── subprocessdata │ │ ├── fd_status.py │ │ ├── input_reader.py │ │ ├── qcat.py │ │ ├── qgrep.py │ │ └── sigchild_ignore.py │ ├── test_asyncore.py │ ├── test_ftplib.py │ ├── test_httplib.py │ ├── test_httpservers.py │ ├── test_queue.py │ ├── test_select.py │ ├── test_signal.py │ ├── test_smtplib.py │ ├── test_socket.py │ ├── test_socketserver.py │ ├── test_ssl.py │ ├── test_subprocess.py │ ├── test_telnetlib.py │ ├── test_thread.py │ ├── test_threading.py │ ├── test_threading_local.py │ ├── test_timeout.py │ ├── test_urllib.py │ ├── test_urllib2.py │ ├── test_urllib2_localnet.py │ ├── test_urllib2net.py │ ├── test_wsgiref.py │ └── version ├── 3.4 │ ├── badcert.pem │ ├── badkey.pem │ ├── https_svn_python_org_root.pem │ ├── keycert.pem │ ├── lock_tests.py │ ├── nokia.pem │ ├── nullcert.pem │ ├── sha256.pem │ ├── subprocessdata │ │ ├── fd_status.py │ │ ├── input_reader.py │ │ ├── qcat.py │ │ ├── qgrep.py │ │ └── sigchild_ignore.py │ ├── test_asyncore.py │ ├── test_ftplib.py │ ├── test_httplib.py │ ├── test_httpservers.py │ ├── test_queue.py │ ├── test_select.py │ ├── test_signal.py │ ├── test_smtplib.py │ ├── test_socket.py │ ├── test_socketserver.py │ ├── test_ssl.py │ ├── test_subprocess.py │ ├── test_telnetlib.py │ ├── test_thread.py │ ├── test_threading.py │ ├── test_threading_local.py │ ├── test_timeout.py │ ├── test_urllib.py │ ├── test_urllib2.py │ ├── test_urllib2_localnet.py │ ├── test_urllib2net.py │ ├── test_wsgiref.py │ └── version ├── badcert.pem ├── badkey.pem ├── bench_sendall.py ├── bench_sleep0.py ├── bench_spawn.py ├── greentest.py ├── https_svn_python_org_root.pem ├── keycert.pem ├── lock_tests.py ├── monkey_test.py ├── nullcert.pem ├── patched_tests_setup.py ├── sha256.pem ├── six.py ├── test__GreenletExit.py ├── test___example_servers.py ├── test___monkey_patching.py ├── test__all__.py ├── test__api.py ├── test__api_timeout.py ├── test__ares_host_result.py ├── test__backdoor.py ├── test__core.py ├── test__core_async.py ├── test__core_callback.py ├── test__core_loop_run.py ├── test__core_stat.py ├── test__core_timer.py ├── test__core_watcher.py ├── test__destroy.py ├── test__doctests.py ├── test__environ.py ├── test__event.py ├── test__example_echoserver.py ├── test__example_portforwarder.py ├── test__example_udp_client.py ├── test__example_udp_server.py ├── test__examples.py ├── test__exc_info.py ├── test__execmodules.py ├── test__fileobject.py ├── test__greenio.py ├── test__greenlet.py ├── test__greenletset.py ├── test__greenness.py ├── test__hub.py ├── test__issue302monkey.py ├── test__issue6.py ├── test__joinall.py ├── test__local.py ├── test__loop_callback.py ├── test__makefile_ref.py ├── test__memleak.py ├── test__monkey.py ├── test__nondefaultloop.py ├── test__order.py ├── test__os.py ├── test__pool.py ├── test__pywsgi.py ├── test__queue.py ├── test__real_greenlet.py ├── test__refcount.py ├── test__refcount_core.py ├── test__select.py ├── test__semaphore.py ├── test__server.py ├── test__server_pywsgi.py ├── test__signal.py ├── test__sleep0.py ├── test__socket.py ├── test__socket_close.py ├── test__socket_dns.py ├── test__socket_dns6.py ├── test__socket_errors.py ├── test__socket_ex.py ├── test__socket_ssl.py ├── test__socket_timeout.py ├── test__socketpair.py ├── test__ssl.py ├── test__subprocess.py ├── test__subprocess_interrupted.py ├── test__subprocess_poll.py ├── test__systemerror.py ├── test__threading.py ├── test__threading_patched_local.py ├── test__threading_vs_settrace.py ├── test__threadpool.py ├── test__timeout.py ├── test_ares_timeout.py ├── test_close_backend_fd.py ├── test_hub_join.py ├── test_hub_join_timeout.py ├── test_issue112.py ├── test_queue.py ├── test_server.crt ├── test_server.key ├── test_threading_2.py ├── testrunner.py ├── tests_that_dont_use_resolver.txt ├── util.py ├── wrongcert.pem ├── xtest__benchmarks.py ├── xtest__issue91.py ├── xtest__server_close.py ├── xtest_signal.py └── xtest_stdlib.py ├── known_failures.py ├── libev ├── Changes ├── LICENSE ├── Makefile.in ├── README ├── config.guess ├── config.h.in ├── config.sub ├── configure ├── ev.c ├── ev.h ├── ev_epoll.c ├── ev_kqueue.c ├── ev_poll.c ├── ev_port.c ├── ev_select.c ├── ev_vars.h ├── ev_win32.c ├── ev_wrap.h ├── install-sh ├── ltmain.sh └── missing ├── setup.py └── util ├── cythonpp.py ├── makedeb.sh ├── makedist.py ├── pyflakes.py ├── set_version.py └── wintest.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.py[co] 2 | build/ 3 | *.so 4 | gevent.*.[ch] 5 | gevent/core.pyx 6 | *.egg-info 7 | 8 | doc/changelog.rst 9 | doc/_build 10 | doc/gevent.*.rst 11 | !doc/gevent.core.rst 12 | !doc/gevent.event.rst 13 | !doc/gevent.hub.rst 14 | !doc/gevent.queue.rst 15 | -------------------------------------------------------------------------------- /.pep8: -------------------------------------------------------------------------------- 1 | [pep8] 2 | ignore=E702,E265 3 | max_line_length=160 4 | exclude=.git,build,2.6,2.7,2.7pypy,3.3,3.4,test_support.py,test_queue.py,patched_tests_setup.py,test_threading_2.py,lock_tests.py 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - "2.6" 4 | - "2.7" 5 | - "3.3" 6 | - "3.4" 7 | - "pypy" 8 | script: 9 | - if [[ $TRAVIS_PYTHON_VERSION == 'pypy' ]]; then NWORKERS=4 PYTHON=pypy make travis_pypy; fi 10 | - if [[ $TRAVIS_PYTHON_VERSION != 'pypy' ]]; then NWORKERS=4 PYTHON=python$TRAVIS_PYTHON_VERSION make travis_cpython; fi 11 | notifications: 12 | email: false 13 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Gevent is written and maintained by 2 | 3 | Denis Bilenko 4 | 5 | and the contributors (ordered by the date of first contribution): 6 | 7 | Jason Toffaletti 8 | Mike Barton 9 | Ludvig Ericson 10 | Marcus Cavanaugh 11 | Matt Goodall 12 | Ralf Schmitt 13 | Daniele Varrazzo 14 | Nicholas Piël 15 | Örjan Persson 16 | Uriel Katz 17 | Ted Suzman 18 | Randall Leeds 19 | Erik Näslund 20 | Alexey Borzenkov 21 | David Hain 22 | Dmitry Chechik 23 | Ned Rockson 24 | Tommie Gannert 25 | Shaun Lindsay 26 | Andreas Blixt 27 | Nick Barkas 28 | Galfy Pundee 29 | Alexander Boudkar 30 | Damien Churchill 31 | Tom Lynn 32 | Shaun Cutts 33 | David LaBissoniere 34 | Alexandre Kandalintsev 35 | Geert Jansen 36 | Vitaly Kruglikov 37 | Saúl Ibarra Corretgé 38 | Oliver Beattie 39 | Bobby Powers 40 | Anton Patrushev 41 | Jan-Philip Gehrcke 42 | Alex Gaynor 43 | 陈小玉 44 | Philip Conrad 45 | 46 | See https://github.com/surfly/gevent/graphs/contributors for more info. 47 | 48 | Gevent is inspired by and uses some code from eventlet which was written by 49 | 50 | Bob Ipollito 51 | Donovan Preston 52 | 53 | The win32util module is taken from Twisted. 54 | 55 | Some modules (local, ssl) contain code from the Python standard library. 56 | 57 | If your code is used in gevent and you are not mentioned above, please contact the maintainer. 58 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Except when otherwise stated (look at the beginning of each file) the software 2 | and the documentation in this project are copyrighted by: 3 | 4 | Denis Bilenko and the contributors, http://www.gevent.org 5 | 6 | and licensed under the MIT license: 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | recursive-include greentest * 2 | recursive-include examples * 3 | recursive-include gevent * 4 | recursive-include doc * 5 | recursive-include libev * 6 | recursive-include c-ares * 7 | recursive-include util * 8 | include LICENSE 9 | include README.rst 10 | include TODO 11 | include changelog.rst 12 | include MANIFEST.in 13 | include AUTHORS 14 | include Makefile.ext 15 | include known_failures.py 16 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | The issue tracker is hosted at https://github.com/surfly/gevent/issues 2 | -------------------------------------------------------------------------------- /benchmarks/micro.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e -x 3 | python -c 'import gevent.core; from __future__ import print_function; print(gevent.__version__, gevent.core.get_version(), getattr(gevent.core, "get_method", lambda: "n/a")(), getattr(gevent, "get_hub", lambda: "n/a")())' 4 | python -mtimeit -r 6 -s'obj = Exception(); obj.x=5' 'obj.x' 5 | python -mtimeit -r 6 -s'from gevent import get_hub; get_hub()' 'get_hub()' 6 | python -mtimeit -r 6 -s'from gevent import getcurrent' 'getcurrent()' 7 | 8 | python -mtimeit -r 6 -s'from gevent.lock import Semaphore; s = Semaphore()' 's.release()' 9 | python -mtimeit -r 6 -s'from gevent.coros import Semaphore; from gevent import spawn_raw; s = Semaphore(0)' 'spawn_raw(s.release); s.acquire()' 10 | python -mtimeit -r 6 -s'from gevent.coros import Semaphore; from gevent import spawn_raw; s = Semaphore(0)' 'spawn_raw(s.release); spawn_raw(s.release); spawn_raw(s.release); spawn_raw(s.release); s.acquire(); s.acquire(); s.acquire(); s.acquire()' 11 | 12 | python -mtimeit -r 6 -s'from gevent import spawn; f = lambda : 5' 'spawn(f)' 13 | python -mtimeit -r 6 -s'from gevent import spawn; f = lambda : 5' 'spawn(f).join()' 14 | python -mtimeit -r 6 -s'from gevent import spawn, run; from gevent.hub import xrange; f = lambda : 5' 'for _ in xrange(10000): spawn(f)' 'run()' 15 | python -mtimeit -r 6 -s'from gevent import spawn_raw; f = lambda : 5' 'spawn_raw(f)' 16 | 17 | python -mtimeit -r 6 -s'from gevent import sleep; f = lambda : 5' 'sleep(0)' 18 | python -mtimeit -r 6 -s'from gevent import sleep; f = lambda : 5' 'sleep(0.0001)' 19 | 20 | benchmarks/micro_run_callback.sh 21 | benchmarks/micro_semaphore.sh 22 | benchmarks/micro_sleep.sh 23 | benchmarks/micro_greenlet_link.sh 24 | -------------------------------------------------------------------------------- /benchmarks/micro_greenlet_link.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e -x 3 | python -mtimeit -r 6 -s'from gevent import spawn; from gevent.hub import xrange; g = spawn(lambda: 5); l = lambda: 5' 'for _ in xrange(1000): g.link(l)' 4 | python -mtimeit -r 6 -s'from gevent import spawn; from gevent.hub import xrange; g = spawn(lambda: 5); l = lambda *args: 5' 'for _ in xrange(10): g.link(l);' 'g.join()' 5 | python -mtimeit -r 6 -s'from gevent import spawn; from gevent.hub import xrange; g = spawn(lambda: 5); l = lambda *args: 5' 'for _ in xrange(100): g.link(l);' 'g.join()' 6 | python -mtimeit -r 6 -s'from gevent import spawn; from gevent.hub import xrange; g = spawn(lambda: 5); l = lambda *args: 5' 'for _ in xrange(1000): g.link(l);' 'g.join()' 7 | python -mtimeit -r 6 -s'from gevent import spawn; from gevent.hub import xrange; g = spawn(lambda: 5); l = lambda *args: 5' 'for _ in xrange(10000): g.link(l);' 'g.join()' 8 | python -mtimeit -r 6 -s'from gevent import spawn; from gevent.hub import xrange; g = spawn(lambda: 5); l = lambda *args: 5' 'for _ in xrange(100000): g.link(l);' 'g.join()' 9 | -------------------------------------------------------------------------------- /benchmarks/micro_run_callback.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e -x 3 | python -mtimeit -r 6 -s'from gevent import run,get_hub; run_cb = get_hub().loop.run_callback; f = lambda : 5' 'run_cb(f)' 4 | python -mtimeit -r 6 -s'from gevent import run,get_hub; run_cb = get_hub().loop.run_callback; f = lambda : 5' 'run_cb(f)' 'run()' 5 | python -mtimeit -r 6 -s'from gevent import run,get_hub; from gevent.hub import xrange; run_cb = get_hub().loop.run_callback; f = lambda : 5' 'for _ in xrange(100): run_cb(f)' 6 | python -mtimeit -r 6 -s'from gevent import run,get_hub; from gevent.hub import xrange; run_cb = get_hub().loop.run_callback; f = lambda : 5' 'for _ in xrange(100): run_cb(f)' 'run()' 7 | python -mtimeit -r 6 -s'from gevent import run,get_hub; from gevent.hub import xrange; run_cb = get_hub().loop.run_callback; f = lambda : 5' 'for _ in xrange(10000): run_cb(f)' 8 | python -mtimeit -r 6 -s'from gevent import run,get_hub; from gevent.hub import xrange; run_cb = get_hub().loop.run_callback; f = lambda : 5' 'for _ in xrange(10000): run_cb(f)' 'run()' 9 | 10 | 11 | -------------------------------------------------------------------------------- /benchmarks/micro_semaphore.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e -x 3 | python -mtimeit -r 6 -s'from gevent.lock import Semaphore; s = Semaphore()' 's.release()' 4 | python -mtimeit -r 6 -s'from gevent.coros import Semaphore; from gevent import spawn_raw; s = Semaphore(0)' 'spawn_raw(s.release); s.acquire()' 5 | python -mtimeit -r 6 -s'from gevent.coros import Semaphore; from gevent import spawn_raw; s = Semaphore(0)' 'spawn_raw(s.release); spawn_raw(s.release); spawn_raw(s.release); spawn_raw(s.release); s.acquire(); s.acquire(); s.acquire(); s.acquire()' 6 | -------------------------------------------------------------------------------- /benchmarks/micro_sleep.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e -x 3 | python -mtimeit -r 6 -s'from gevent import sleep; f = lambda : 5' 'sleep(0)' 4 | python -mtimeit -r 6 -s'from gevent import sleep; f = lambda : 5' 'sleep(0.00001)' 5 | python -mtimeit -r 6 -s'from gevent import sleep; f = lambda : 5' 'sleep(0.0001)' 6 | python -mtimeit -r 6 -s'from gevent import sleep; f = lambda : 5' 'sleep(0.001)' 7 | -------------------------------------------------------------------------------- /c-ares/AUTHORS: -------------------------------------------------------------------------------- 1 | c-ares is based on ares, and these are the people that have worked on it since 2 | the fork was made: 3 | 4 | Albert Chin 5 | Alexander Lazic 6 | Alexey Simak 7 | Andreas Rieke 8 | Andrew C. Morrow 9 | Ashish Sharma 10 | Ben Greear 11 | Ben Noordhuis 12 | BogDan Vatra 13 | Brad House 14 | Brad Spencer 15 | Bram Matthys 16 | Dan Fandrich 17 | Daniel Johnson 18 | Daniel Stenberg 19 | David Stuart 20 | Denis Bilenko 21 | Dima Tisnek 22 | Dirk Manske 23 | Dominick Meglio 24 | Doug Goldstein 25 | Duncan Wilcox 26 | Eino Tuominen 27 | Erik Kline 28 | George Neill 29 | Gisle Vanem 30 | Guenter Knauf 31 | Guilherme Balena Versiani 32 | Gunter Knauf 33 | Henrik Stoerner 34 | Jakub Hrozek 35 | James Bursa 36 | Jérémy Lal 37 | Marko Kreen 38 | Michael Wallner 39 | Mike Crowe 40 | Nick Alcock 41 | Nick Mathewson 42 | Patrik Thunstrom 43 | Peter Pentchev 44 | Phil Blundell 45 | Poul Thomas Lomholt 46 | Ravi Pratap 47 | Robin Cornelius 48 | Sebastian at basti79.de 49 | Shmulik Regev 50 | Stefan Bühler 51 | Steinar H. Gunderson 52 | Tofu Linden 53 | Tom Hughes 54 | Tor Arntsen 55 | Vlad Dinulescu 56 | William Ahern 57 | Yang Tse 58 | liren at vivisimo.com 59 | -------------------------------------------------------------------------------- /c-ares/CHANGES: -------------------------------------------------------------------------------- 1 | This file no longer holds the changelog. Now you can generate it yourself 2 | like this: 3 | 4 | $ git log --pretty=fuller --no-color --date=short --decorate=full -1000 | 5 | ./git2changes.pl 6 | 7 | The older, manually edited, changelog is found in git named CHANGES.0 8 | -------------------------------------------------------------------------------- /c-ares/CHANGES.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantix/gevent/71dd2d4d1d3332ed87f79c19d54d97bdcacdcf6d/c-ares/CHANGES.0 -------------------------------------------------------------------------------- /c-ares/README.cares: -------------------------------------------------------------------------------- 1 | c-ares 2 | ====== 3 | 4 | This package is based on ares 1.1.1 (written by Greg Hudson). I decided to 5 | fork and release a separate project since the ares author didn't want the 6 | improvements that were vital for our use of it. 7 | 8 | This package is dubbed 'c-ares' since I (Daniel Stenberg) wanted this for use 9 | within the curl project (hence the letter C) and it makes a nice pun. Also, 10 | c-ares is not API compatible with ares: a new name makes that more obvious to 11 | the public. 12 | 13 | The original libares was distributed at athena-dist.mit.edu:pub/ATHENA/ares. 14 | -------------------------------------------------------------------------------- /c-ares/RELEASE-NOTES: -------------------------------------------------------------------------------- 1 | c-ares version 1.9.1 2 | 3 | Fixed: 4 | 5 | o include the ares_parse_soa_reply.* files in the tarball 6 | 7 | Thanks go to these friendly people for their efforts and contributions: 8 | 9 | Eugeny Gladkih 10 | 11 | Have fun! 12 | -------------------------------------------------------------------------------- /c-ares/TODO: -------------------------------------------------------------------------------- 1 | TODO 2 | ==== 3 | 4 | ares_reinit() 5 | 6 | - To allow an app to force a re-read of /etc/resolv.conf etc, pretty much 7 | like the res_init() resolver function offers 8 | 9 | ares_gethostbyname 10 | 11 | - When built to support IPv6, it needs to also support PF_UNSPEC or similar, 12 | so that an application can ask for any protocol and then c-ares would return 13 | all known resolves and not just explicitly IPv4 _or_ IPv6 resolves. 14 | 15 | ares_process 16 | 17 | - Upon next ABI breakage ares_process() should be changed to return 'int' 18 | and return ARES_ENOTINITIALIZED if ares_library_init() has not been called. 19 | 20 | ares_process_fd 21 | 22 | - Upon next ABI breakage ares_process_fd() should be changed to return 23 | 'int' and return ARES_ENOTINITIALIZED if library has not been initialized. 24 | -------------------------------------------------------------------------------- /c-ares/ares_free_hostent.c: -------------------------------------------------------------------------------- 1 | 2 | /* Copyright 1998 by the Massachusetts Institute of Technology. 3 | * 4 | * Permission to use, copy, modify, and distribute this 5 | * software and its documentation for any purpose and without 6 | * fee is hereby granted, provided that the above copyright 7 | * notice appear in all copies and that both that copyright 8 | * notice and this permission notice appear in supporting 9 | * documentation, and that the name of M.I.T. not be used in 10 | * advertising or publicity pertaining to distribution of the 11 | * software without specific, written prior permission. 12 | * M.I.T. makes no representations about the suitability of 13 | * this software for any purpose. It is provided "as is" 14 | * without express or implied warranty. 15 | */ 16 | 17 | #include "ares_setup.h" 18 | #include 19 | 20 | #ifdef HAVE_NETDB_H 21 | #include 22 | #endif 23 | 24 | #include "ares.h" 25 | #include "ares_private.h" /* for memdebug */ 26 | 27 | void ares_free_hostent(struct hostent *host) 28 | { 29 | char **p; 30 | 31 | if (!host) 32 | return; 33 | 34 | free((char *)(host->h_name)); 35 | for (p = host->h_aliases; *p; p++) 36 | free(*p); 37 | free(host->h_aliases); 38 | free(host->h_addr_list[0]); /* no matter if there is one or many entries, 39 | there is only one malloc for all of them */ 40 | free(host->h_addr_list); 41 | free(host); 42 | } 43 | -------------------------------------------------------------------------------- /c-ares/ares_free_string.c: -------------------------------------------------------------------------------- 1 | 2 | /* Copyright 2000 by the Massachusetts Institute of Technology. 3 | * 4 | * Permission to use, copy, modify, and distribute this 5 | * software and its documentation for any purpose and without 6 | * fee is hereby granted, provided that the above copyright 7 | * notice appear in all copies and that both that copyright 8 | * notice and this permission notice appear in supporting 9 | * documentation, and that the name of M.I.T. not be used in 10 | * advertising or publicity pertaining to distribution of the 11 | * software without specific, written prior permission. 12 | * M.I.T. makes no representations about the suitability of 13 | * this software for any purpose. It is provided "as is" 14 | * without express or implied warranty. 15 | */ 16 | 17 | #include "ares_setup.h" 18 | #include 19 | #include "ares.h" 20 | #include "ares_private.h" 21 | 22 | void ares_free_string(void *str) 23 | { 24 | free(str); 25 | } 26 | -------------------------------------------------------------------------------- /c-ares/ares_getenv.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* Copyright 1998 by the Massachusetts Institute of Technology. 4 | * 5 | * Permission to use, copy, modify, and distribute this 6 | * software and its documentation for any purpose and without 7 | * fee is hereby granted, provided that the above copyright 8 | * notice appear in all copies and that both that copyright 9 | * notice and this permission notice appear in supporting 10 | * documentation, and that the name of M.I.T. not be used in 11 | * advertising or publicity pertaining to distribution of the 12 | * software without specific, written prior permission. 13 | * M.I.T. makes no representations about the suitability of 14 | * this software for any purpose. It is provided "as is" 15 | * without express or implied warranty. 16 | */ 17 | 18 | #include "ares_setup.h" 19 | #include "ares_getenv.h" 20 | 21 | #ifndef HAVE_GETENV 22 | 23 | char *ares_getenv(const char *name) 24 | { 25 | #ifdef _WIN32_WCE 26 | return NULL; 27 | #endif 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /c-ares/ares_getenv.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_CARES_GETENV_H 2 | #define HEADER_CARES_GETENV_H 3 | 4 | 5 | /* Copyright 1998 by the Massachusetts Institute of Technology. 6 | * 7 | * Permission to use, copy, modify, and distribute this 8 | * software and its documentation for any purpose and without 9 | * fee is hereby granted, provided that the above copyright 10 | * notice appear in all copies and that both that copyright 11 | * notice and this permission notice appear in supporting 12 | * documentation, and that the name of M.I.T. not be used in 13 | * advertising or publicity pertaining to distribution of the 14 | * software without specific, written prior permission. 15 | * M.I.T. makes no representations about the suitability of 16 | * this software for any purpose. It is provided "as is" 17 | * without express or implied warranty. 18 | */ 19 | 20 | #include "ares_setup.h" 21 | 22 | #ifndef HAVE_GETENV 23 | extern char *ares_getenv(const char *name); 24 | #endif 25 | 26 | #endif /* HEADER_CARES_GETENV_H */ 27 | -------------------------------------------------------------------------------- /c-ares/ares_library_init.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_CARES_LIBRARY_INIT_H 2 | #define HEADER_CARES_LIBRARY_INIT_H 3 | 4 | 5 | /* Copyright 1998 by the Massachusetts Institute of Technology. 6 | * Copyright (C) 2004-2011 by Daniel Stenberg 7 | * 8 | * Permission to use, copy, modify, and distribute this 9 | * software and its documentation for any purpose and without 10 | * fee is hereby granted, provided that the above copyright 11 | * notice appear in all copies and that both that copyright 12 | * notice and this permission notice appear in supporting 13 | * documentation, and that the name of M.I.T. not be used in 14 | * advertising or publicity pertaining to distribution of the 15 | * software without specific, written prior permission. 16 | * M.I.T. makes no representations about the suitability of 17 | * this software for any purpose. It is provided "as is" 18 | * without express or implied warranty. 19 | */ 20 | 21 | #include "ares_setup.h" 22 | 23 | #ifdef USE_WINSOCK 24 | 25 | #include 26 | #include 27 | 28 | typedef DWORD (WINAPI *fpGetNetworkParams_t) (FIXED_INFO*, DWORD*); 29 | typedef BOOLEAN (APIENTRY *fpSystemFunction036_t) (void*, ULONG); 30 | typedef ULONG (WINAPI *fpGetAdaptersAddresses_t) ( ULONG, ULONG, void*, IP_ADAPTER_ADDRESSES*, ULONG* ); 31 | 32 | /* Forward-declaration of variables defined in ares_library_init.c */ 33 | /* that are global and unique instances for whole c-ares library. */ 34 | 35 | extern fpGetNetworkParams_t ares_fpGetNetworkParams; 36 | extern fpSystemFunction036_t ares_fpSystemFunction036; 37 | extern fpGetAdaptersAddresses_t ares_fpGetAdaptersAddresses; 38 | 39 | #endif /* USE_WINSOCK */ 40 | 41 | #endif /* HEADER_CARES_LIBRARY_INIT_H */ 42 | 43 | -------------------------------------------------------------------------------- /c-ares/ares_llist.h: -------------------------------------------------------------------------------- 1 | #ifndef __ARES_LLIST_H 2 | #define __ARES_LLIST_H 3 | 4 | 5 | /* Copyright 1998 by the Massachusetts Institute of Technology. 6 | * 7 | * Permission to use, copy, modify, and distribute this 8 | * software and its documentation for any purpose and without 9 | * fee is hereby granted, provided that the above copyright 10 | * notice appear in all copies and that both that copyright 11 | * notice and this permission notice appear in supporting 12 | * documentation, and that the name of M.I.T. not be used in 13 | * advertising or publicity pertaining to distribution of the 14 | * software without specific, written prior permission. 15 | * M.I.T. makes no representations about the suitability of 16 | * this software for any purpose. It is provided "as is" 17 | * without express or implied warranty. 18 | */ 19 | 20 | 21 | /* Node definition for circular, doubly-linked list */ 22 | struct list_node { 23 | struct list_node *prev; 24 | struct list_node *next; 25 | void* data; 26 | }; 27 | 28 | void ares__init_list_head(struct list_node* head); 29 | 30 | void ares__init_list_node(struct list_node* node, void* d); 31 | 32 | int ares__is_list_empty(struct list_node* head); 33 | 34 | void ares__insert_in_list(struct list_node* new_node, 35 | struct list_node* old_node); 36 | 37 | void ares__remove_from_list(struct list_node* node); 38 | 39 | void ares__swap_lists(struct list_node* head_a, 40 | struct list_node* head_b); 41 | 42 | #endif /* __ARES_LLIST_H */ 43 | -------------------------------------------------------------------------------- /c-ares/ares_mkquery.c: -------------------------------------------------------------------------------- 1 | 2 | /* Copyright 1998 by the Massachusetts Institute of Technology. 3 | * 4 | * Permission to use, copy, modify, and distribute this 5 | * software and its documentation for any purpose and without 6 | * fee is hereby granted, provided that the above copyright 7 | * notice appear in all copies and that both that copyright 8 | * notice and this permission notice appear in supporting 9 | * documentation, and that the name of M.I.T. not be used in 10 | * advertising or publicity pertaining to distribution of the 11 | * software without specific, written prior permission. 12 | * M.I.T. makes no representations about the suitability of 13 | * this software for any purpose. It is provided "as is" 14 | * without express or implied warranty. 15 | */ 16 | 17 | #include "ares_setup.h" 18 | #include "ares.h" 19 | 20 | int ares_mkquery(const char *name, int dnsclass, int type, unsigned short id, 21 | int rd, unsigned char **buf, int *buflen) 22 | { 23 | return ares_create_query(name, dnsclass, type, id, rd, buf, buflen, 0); 24 | } 25 | -------------------------------------------------------------------------------- /c-ares/ares_nowarn.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_CARES_NOWARN_H 2 | #define HEADER_CARES_NOWARN_H 3 | 4 | 5 | /* Copyright (C) 2010-2012 by Daniel Stenberg 6 | * 7 | * Permission to use, copy, modify, and distribute this 8 | * software and its documentation for any purpose and without 9 | * fee is hereby granted, provided that the above copyright 10 | * notice appear in all copies and that both that copyright 11 | * notice and this permission notice appear in supporting 12 | * documentation, and that the name of M.I.T. not be used in 13 | * advertising or publicity pertaining to distribution of the 14 | * software without specific, written prior permission. 15 | * M.I.T. makes no representations about the suitability of 16 | * this software for any purpose. It is provided "as is" 17 | * without express or implied warranty. 18 | */ 19 | 20 | long aresx_uztosl(size_t uznum); 21 | int aresx_uztosi(size_t uznum); 22 | short aresx_uztoss(size_t uznum); 23 | 24 | short aresx_sitoss(int sinum); 25 | 26 | int aresx_sltosi(long slnum); 27 | 28 | int aresx_sztosi(ssize_t sznum); 29 | 30 | unsigned int aresx_sztoui(ssize_t sznum); 31 | 32 | unsigned short aresx_sitous(int sinum); 33 | 34 | #if defined(__INTEL_COMPILER) && defined(__unix__) 35 | 36 | int aresx_FD_ISSET(int fd, fd_set *fdset); 37 | 38 | void aresx_FD_SET(int fd, fd_set *fdset); 39 | 40 | void aresx_FD_ZERO(fd_set *fdset); 41 | 42 | unsigned short aresx_htons(unsigned short usnum); 43 | 44 | unsigned short aresx_ntohs(unsigned short usnum); 45 | 46 | #ifndef BUILDING_ARES_NOWARN_C 47 | # undef FD_ISSET 48 | # define FD_ISSET(a,b) aresx_FD_ISSET((a),(b)) 49 | # undef FD_SET 50 | # define FD_SET(a,b) aresx_FD_SET((a),(b)) 51 | # undef FD_ZERO 52 | # define FD_ZERO(a) aresx_FD_ZERO((a)) 53 | # undef htons 54 | # define htons(a) aresx_htons((a)) 55 | # undef ntohs 56 | # define ntohs(a) aresx_ntohs((a)) 57 | #endif 58 | 59 | #endif /* __INTEL_COMPILER && __unix__ */ 60 | 61 | #endif /* HEADER_CARES_NOWARN_H */ 62 | -------------------------------------------------------------------------------- /c-ares/ares_platform.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_CARES_PLATFORM_H 2 | #define HEADER_CARES_PLATFORM_H 3 | 4 | 5 | /* Copyright 1998 by the Massachusetts Institute of Technology. 6 | * Copyright (C) 2004 - 2011 by Daniel Stenberg et al 7 | * 8 | * Permission to use, copy, modify, and distribute this 9 | * software and its documentation for any purpose and without 10 | * fee is hereby granted, provided that the above copyright 11 | * notice appear in all copies and that both that copyright 12 | * notice and this permission notice appear in supporting 13 | * documentation, and that the name of M.I.T. not be used in 14 | * advertising or publicity pertaining to distribution of the 15 | * software without specific, written prior permission. 16 | * M.I.T. makes no representations about the suitability of 17 | * this software for any purpose. It is provided "as is" 18 | * without express or implied warranty. 19 | */ 20 | 21 | #include "ares_setup.h" 22 | 23 | #if defined(WIN32) && !defined(MSDOS) 24 | 25 | typedef enum { 26 | WIN_UNKNOWN, 27 | WIN_3X, 28 | WIN_9X, 29 | WIN_NT, 30 | WIN_CE 31 | } win_platform; 32 | 33 | win_platform ares__getplatform(void); 34 | 35 | #endif 36 | 37 | #if defined(_WIN32_WCE) 38 | 39 | struct servent *getservbyport(int port, const char *proto); 40 | 41 | #endif 42 | 43 | #endif /* HEADER_CARES_PLATFORM_H */ 44 | -------------------------------------------------------------------------------- /c-ares/ares_strcasecmp.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* Copyright 1998 by the Massachusetts Institute of Technology. 4 | * 5 | * Permission to use, copy, modify, and distribute this 6 | * software and its documentation for any purpose and without 7 | * fee is hereby granted, provided that the above copyright 8 | * notice appear in all copies and that both that copyright 9 | * notice and this permission notice appear in supporting 10 | * documentation, and that the name of M.I.T. not be used in 11 | * advertising or publicity pertaining to distribution of the 12 | * software without specific, written prior permission. 13 | * M.I.T. makes no representations about the suitability of 14 | * this software for any purpose. It is provided "as is" 15 | * without express or implied warranty. 16 | */ 17 | 18 | #include "ares_setup.h" 19 | #include "ares_strcasecmp.h" 20 | 21 | #ifndef HAVE_STRCASECMP 22 | int ares_strcasecmp(const char *a, const char *b) 23 | { 24 | #if defined(HAVE_STRCMPI) 25 | return strcmpi(a, b); 26 | #elif defined(HAVE_STRICMP) 27 | return stricmp(a, b); 28 | #else 29 | size_t i; 30 | 31 | for (i = 0; i < (size_t)-1; i++) { 32 | int c1 = ISUPPER(a[i]) ? tolower(a[i]) : a[i]; 33 | int c2 = ISUPPER(b[i]) ? tolower(b[i]) : b[i]; 34 | if (c1 != c2) 35 | return c1-c2; 36 | if (!c1) 37 | break; 38 | } 39 | return 0; 40 | #endif 41 | } 42 | #endif 43 | 44 | #ifndef HAVE_STRNCASECMP 45 | int ares_strncasecmp(const char *a, const char *b, size_t n) 46 | { 47 | #if defined(HAVE_STRNCMPI) 48 | return strncmpi(a, b, n); 49 | #elif defined(HAVE_STRNICMP) 50 | return strnicmp(a, b, n); 51 | #else 52 | size_t i; 53 | 54 | for (i = 0; i < n; i++) { 55 | int c1 = ISUPPER(a[i]) ? tolower(a[i]) : a[i]; 56 | int c2 = ISUPPER(b[i]) ? tolower(b[i]) : b[i]; 57 | if (c1 != c2) 58 | return c1-c2; 59 | if (!c1) 60 | break; 61 | } 62 | return 0; 63 | #endif 64 | } 65 | #endif 66 | 67 | -------------------------------------------------------------------------------- /c-ares/ares_strcasecmp.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_CARES_STRCASECMP_H 2 | #define HEADER_CARES_STRCASECMP_H 3 | 4 | 5 | /* Copyright 1998 by the Massachusetts Institute of Technology. 6 | * 7 | * Permission to use, copy, modify, and distribute this 8 | * software and its documentation for any purpose and without 9 | * fee is hereby granted, provided that the above copyright 10 | * notice appear in all copies and that both that copyright 11 | * notice and this permission notice appear in supporting 12 | * documentation, and that the name of M.I.T. not be used in 13 | * advertising or publicity pertaining to distribution of the 14 | * software without specific, written prior permission. 15 | * M.I.T. makes no representations about the suitability of 16 | * this software for any purpose. It is provided "as is" 17 | * without express or implied warranty. 18 | */ 19 | 20 | #include "ares_setup.h" 21 | 22 | #ifndef HAVE_STRCASECMP 23 | extern int ares_strcasecmp(const char *a, const char *b); 24 | #endif 25 | 26 | #ifndef HAVE_STRNCASECMP 27 | extern int ares_strncasecmp(const char *a, const char *b, size_t n); 28 | #endif 29 | 30 | #endif /* HEADER_CARES_STRCASECMP_H */ 31 | -------------------------------------------------------------------------------- /c-ares/ares_strdup.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* Copyright 1998 by the Massachusetts Institute of Technology. 4 | * 5 | * Permission to use, copy, modify, and distribute this 6 | * software and its documentation for any purpose and without 7 | * fee is hereby granted, provided that the above copyright 8 | * notice appear in all copies and that both that copyright 9 | * notice and this permission notice appear in supporting 10 | * documentation, and that the name of M.I.T. not be used in 11 | * advertising or publicity pertaining to distribution of the 12 | * software without specific, written prior permission. 13 | * M.I.T. makes no representations about the suitability of 14 | * this software for any purpose. It is provided "as is" 15 | * without express or implied warranty. 16 | */ 17 | 18 | #include "ares_setup.h" 19 | #include "ares_strdup.h" 20 | 21 | #ifndef HAVE_STRDUP 22 | char *ares_strdup(const char *s1) 23 | { 24 | size_t sz; 25 | char * s2; 26 | 27 | if(s1) { 28 | sz = strlen(s1); 29 | if(sz < (size_t)-1) { 30 | sz++; 31 | if(sz < ((size_t)-1) / sizeof(char)) { 32 | s2 = malloc(sz * sizeof(char)); 33 | if(s2) { 34 | memcpy(s2, s1, sz * sizeof(char)); 35 | return s2; 36 | } 37 | } 38 | } 39 | } 40 | return (char *)NULL; 41 | } 42 | #endif 43 | -------------------------------------------------------------------------------- /c-ares/ares_strdup.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_CARES_STRDUP_H 2 | #define HEADER_CARES_STRDUP_H 3 | 4 | 5 | /* Copyright 1998 by the Massachusetts Institute of Technology. 6 | * 7 | * Permission to use, copy, modify, and distribute this 8 | * software and its documentation for any purpose and without 9 | * fee is hereby granted, provided that the above copyright 10 | * notice appear in all copies and that both that copyright 11 | * notice and this permission notice appear in supporting 12 | * documentation, and that the name of M.I.T. not be used in 13 | * advertising or publicity pertaining to distribution of the 14 | * software without specific, written prior permission. 15 | * M.I.T. makes no representations about the suitability of 16 | * this software for any purpose. It is provided "as is" 17 | * without express or implied warranty. 18 | */ 19 | 20 | #include "ares_setup.h" 21 | 22 | #ifndef HAVE_STRDUP 23 | extern char *ares_strdup(const char *s1); 24 | #endif 25 | 26 | #endif /* HEADER_CARES_STRDUP_H */ 27 | -------------------------------------------------------------------------------- /c-ares/ares_strerror.c: -------------------------------------------------------------------------------- 1 | 2 | /* Copyright 1998 by the Massachusetts Institute of Technology. 3 | * 4 | * Permission to use, copy, modify, and distribute this 5 | * software and its documentation for any purpose and without 6 | * fee is hereby granted, provided that the above copyright 7 | * notice appear in all copies and that both that copyright 8 | * notice and this permission notice appear in supporting 9 | * documentation, and that the name of M.I.T. not be used in 10 | * advertising or publicity pertaining to distribution of the 11 | * software without specific, written prior permission. 12 | * M.I.T. makes no representations about the suitability of 13 | * this software for any purpose. It is provided "as is" 14 | * without express or implied warranty. 15 | */ 16 | 17 | #include "ares_setup.h" 18 | #include 19 | #include "ares.h" 20 | 21 | const char *ares_strerror(int code) 22 | { 23 | /* Return a string literal from a table. */ 24 | const char *errtext[] = { 25 | "Successful completion", 26 | "DNS server returned answer with no data", 27 | "DNS server claims query was misformatted", 28 | "DNS server returned general failure", 29 | "Domain name not found", 30 | "DNS server does not implement requested operation", 31 | "DNS server refused query", 32 | "Misformatted DNS query", 33 | "Misformatted domain name", 34 | "Unsupported address family", 35 | "Misformatted DNS reply", 36 | "Could not contact DNS servers", 37 | "Timeout while contacting DNS servers", 38 | "End of file", 39 | "Error reading file", 40 | "Out of memory", 41 | "Channel is being destroyed", 42 | "Misformatted string", 43 | "Illegal flags specified", 44 | "Given hostname is not numeric", 45 | "Illegal hints flags specified", 46 | "c-ares library initialization not yet performed", 47 | "Error loading iphlpapi.dll", 48 | "Could not find GetNetworkParams function", 49 | "DNS query cancelled" 50 | }; 51 | 52 | if(code >= 0 && code < (int)(sizeof(errtext) / sizeof(*errtext))) 53 | return errtext[code]; 54 | else 55 | return "unknown"; 56 | } 57 | -------------------------------------------------------------------------------- /c-ares/ares_version.c: -------------------------------------------------------------------------------- 1 | 2 | #include "ares_setup.h" 3 | #include "ares.h" 4 | 5 | const char *ares_version(int *version) 6 | { 7 | if(version) 8 | *version = ARES_VERSION; 9 | 10 | return ARES_VERSION_STR; 11 | } 12 | -------------------------------------------------------------------------------- /c-ares/ares_version.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef ARES__VERSION_H 3 | #define ARES__VERSION_H 4 | 5 | /* This is the global package copyright */ 6 | #define ARES_COPYRIGHT "2004 - 2012 Daniel Stenberg, ." 7 | 8 | #define ARES_VERSION_MAJOR 1 9 | #define ARES_VERSION_MINOR 10 10 | #define ARES_VERSION_PATCH 0 11 | #define ARES_VERSION ((ARES_VERSION_MAJOR<<16)|\ 12 | (ARES_VERSION_MINOR<<8)|\ 13 | (ARES_VERSION_PATCH)) 14 | #define ARES_VERSION_STR "1.10.0-DEV" 15 | 16 | #if (ARES_VERSION >= 0x010700) 17 | # define CARES_HAVE_ARES_LIBRARY_INIT 1 18 | # define CARES_HAVE_ARES_LIBRARY_CLEANUP 1 19 | #else 20 | # undef CARES_HAVE_ARES_LIBRARY_INIT 21 | # undef CARES_HAVE_ARES_LIBRARY_CLEANUP 22 | #endif 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /c-ares/ares_writev.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* Copyright 1998 by the Massachusetts Institute of Technology. 4 | * 5 | * Permission to use, copy, modify, and distribute this 6 | * software and its documentation for any purpose and without 7 | * fee is hereby granted, provided that the above copyright 8 | * notice appear in all copies and that both that copyright 9 | * notice and this permission notice appear in supporting 10 | * documentation, and that the name of M.I.T. not be used in 11 | * advertising or publicity pertaining to distribution of the 12 | * software without specific, written prior permission. 13 | * M.I.T. makes no representations about the suitability of 14 | * this software for any purpose. It is provided "as is" 15 | * without express or implied warranty. 16 | */ 17 | 18 | #include "ares_setup.h" 19 | 20 | #ifdef HAVE_LIMITS_H 21 | # include 22 | #endif 23 | 24 | #include "ares.h" 25 | #include "ares_private.h" 26 | 27 | #ifndef HAVE_WRITEV 28 | ssize_t ares_writev(ares_socket_t s, const struct iovec *iov, int iovcnt) 29 | { 30 | char *buffer, *bp; 31 | int i; 32 | size_t bytes = 0; 33 | ssize_t result; 34 | 35 | /* Validate iovcnt */ 36 | if (iovcnt <= 0) 37 | { 38 | SET_ERRNO(EINVAL); 39 | return (-1); 40 | } 41 | 42 | /* Validate and find the sum of the iov_len values in the iov array */ 43 | for (i = 0; i < iovcnt; i++) 44 | { 45 | if (iov[i].iov_len > INT_MAX - bytes) 46 | { 47 | SET_ERRNO(EINVAL); 48 | return (-1); 49 | } 50 | bytes += iov[i].iov_len; 51 | } 52 | 53 | if (bytes == 0) 54 | return (0); 55 | 56 | /* Allocate a temporary buffer to hold the data */ 57 | buffer = malloc(bytes); 58 | if (!buffer) 59 | { 60 | SET_ERRNO(ENOMEM); 61 | return (-1); 62 | } 63 | 64 | /* Copy the data into buffer */ 65 | for (bp = buffer, i = 0; i < iovcnt; ++i) 66 | { 67 | memcpy (bp, iov[i].iov_base, iov[i].iov_len); 68 | bp += iov[i].iov_len; 69 | } 70 | 71 | /* Send buffer contents */ 72 | result = swrite(s, buffer, bytes); 73 | 74 | free(buffer); 75 | 76 | return (result); 77 | } 78 | #endif 79 | 80 | -------------------------------------------------------------------------------- /c-ares/ares_writev.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_CARES_WRITEV_H 2 | #define HEADER_CARES_WRITEV_H 3 | 4 | 5 | /* Copyright 1998 by the Massachusetts Institute of Technology. 6 | * 7 | * Permission to use, copy, modify, and distribute this 8 | * software and its documentation for any purpose and without 9 | * fee is hereby granted, provided that the above copyright 10 | * notice appear in all copies and that both that copyright 11 | * notice and this permission notice appear in supporting 12 | * documentation, and that the name of M.I.T. not be used in 13 | * advertising or publicity pertaining to distribution of the 14 | * software without specific, written prior permission. 15 | * M.I.T. makes no representations about the suitability of 16 | * this software for any purpose. It is provided "as is" 17 | * without express or implied warranty. 18 | */ 19 | 20 | #include "ares_setup.h" 21 | #include "ares.h" 22 | 23 | #ifndef HAVE_WRITEV 24 | 25 | /* Structure for scatter/gather I/O. */ 26 | struct iovec 27 | { 28 | void *iov_base; /* Pointer to data. */ 29 | size_t iov_len; /* Length of data. */ 30 | }; 31 | 32 | extern ssize_t ares_writev(ares_socket_t s, const struct iovec *iov, int iovcnt); 33 | 34 | #endif 35 | 36 | #endif /* HEADER_CARES_WRITEV_H */ 37 | -------------------------------------------------------------------------------- /c-ares/bitncmp.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") 4 | * Copyright (c) 1996,1999 by Internet Software Consortium. 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 16 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | #ifndef HAVE_BITNCMP 20 | 21 | #include "ares_setup.h" 22 | #include "bitncmp.h" 23 | 24 | /* 25 | * int 26 | * bitncmp(l, r, n) 27 | * compare bit masks l and r, for n bits. 28 | * return: 29 | * -1, 1, or 0 in the libc tradition. 30 | * note: 31 | * network byte order assumed. this means 192.5.5.240/28 has 32 | * 0x11110000 in its fourth octet. 33 | * author: 34 | * Paul Vixie (ISC), June 1996 35 | */ 36 | int 37 | ares_bitncmp(const void *l, const void *r, int n) { 38 | unsigned int lb, rb; 39 | int x, b; 40 | 41 | b = n / 8; 42 | x = memcmp(l, r, b); 43 | if (x || (n % 8) == 0) 44 | return (x); 45 | 46 | lb = ((const unsigned char *)l)[b]; 47 | rb = ((const unsigned char *)r)[b]; 48 | for (b = n % 8; b > 0; b--) { 49 | if ((lb & 0x80) != (rb & 0x80)) { 50 | if (lb & 0x80) 51 | return (1); 52 | return (-1); 53 | } 54 | lb <<= 1; 55 | rb <<= 1; 56 | } 57 | return (0); 58 | } 59 | #endif 60 | -------------------------------------------------------------------------------- /c-ares/bitncmp.h: -------------------------------------------------------------------------------- 1 | #ifndef __ARES_BITNCMP_H 2 | #define __ARES_BITNCMP_H 3 | 4 | 5 | /* Copyright (C) 2005 by Dominick Meglio 6 | * 7 | * Permission to use, copy, modify, and distribute this 8 | * software and its documentation for any purpose and without 9 | * fee is hereby granted, provided that the above copyright 10 | * notice appear in all copies and that both that copyright 11 | * notice and this permission notice appear in supporting 12 | * documentation, and that the name of M.I.T. not be used in 13 | * advertising or publicity pertaining to distribution of the 14 | * software without specific, written prior permission. 15 | * M.I.T. makes no representations about the suitability of 16 | * this software for any purpose. It is provided "as is" 17 | * without express or implied warranty. 18 | */ 19 | 20 | #ifndef HAVE_BITNCMP 21 | int ares_bitncmp(const void *l, const void *r, int n); 22 | #else 23 | #define ares_bitncmp(x,y,z) bitncmp(x,y,z) 24 | #endif 25 | 26 | #endif /* __ARES_BITNCMP_H */ 27 | -------------------------------------------------------------------------------- /c-ares/get_ver.awk: -------------------------------------------------------------------------------- 1 | # *************************************************************************** 2 | # * Project: c-ares 3 | # * 4 | # *************************************************************************** 5 | # awk script which fetches c-ares version number and string from input 6 | # file and writes them to STDOUT. Here you can get an awk version for Win32: 7 | # http://www.gknw.net/development/prgtools/awk-20100523.zip 8 | # 9 | BEGIN { 10 | while ((getline < ARGV[1]) > 0) { 11 | sub("\r", "") # make MSYS gawk work with CRLF header input. 12 | if (match ($0, /^#define ARES_COPYRIGHT "[^"]+"$/)) 13 | copyright_string = substr($0, 25, length($0)-25) 14 | else if (match ($0, /^#define ARES_VERSION_STR "[^"]+"$/)) 15 | version_string = substr($3, 2, length($3)-2) 16 | else if (match ($0, /^#define ARES_VERSION_MAJOR [0-9]+$/)) 17 | version_major = $3 18 | else if (match ($0, /^#define ARES_VERSION_MINOR [0-9]+$/)) 19 | version_minor = $3 20 | else if (match ($0, /^#define ARES_VERSION_PATCH [0-9]+$/)) 21 | version_patch = $3 22 | } 23 | print "LIBCARES_VERSION = " version_major "," version_minor "," version_patch 24 | print "LIBCARES_VERSION_STR = " version_string 25 | print "LIBCARES_COPYRIGHT_STR = " copyright_string 26 | } 27 | 28 | -------------------------------------------------------------------------------- /c-ares/gitinfo: -------------------------------------------------------------------------------- 1 | cares-1_9_1-12-g805c736 2 | -------------------------------------------------------------------------------- /c-ares/inet_net_pton.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_CARES_INET_NET_PTON_H 2 | #define HEADER_CARES_INET_NET_PTON_H 3 | 4 | /* Copyright (C) 2005-2010 by Daniel Stenberg et al 5 | * 6 | * Permission to use, copy, modify, and distribute this 7 | * software and its documentation for any purpose and without 8 | * fee is hereby granted, provided that the above copyright 9 | * notice appear in all copies and that both that copyright 10 | * notice and this permission notice appear in supporting 11 | * documentation, and that the name of M.I.T. not be used in 12 | * advertising or publicity pertaining to distribution of the 13 | * software without specific, written prior permission. 14 | * M.I.T. makes no representations about the suitability of 15 | * this software for any purpose. It is provided "as is" 16 | * without express or implied warranty. 17 | */ 18 | 19 | #ifdef HAVE_INET_PTON 20 | #define ares_inet_pton(x,y,z) inet_pton(x,y,z) 21 | #else 22 | int ares_inet_pton(int af, const char *src, void *dst); 23 | #endif 24 | 25 | #ifdef HAVE_INET_NET_PTON 26 | #define ares_inet_net_pton(w,x,y,z) inet_net_pton(w,x,y,z) 27 | #else 28 | int ares_inet_net_pton(int af, const char *src, void *dst, size_t size); 29 | #endif 30 | 31 | #endif /* HEADER_CARES_INET_NET_PTON_H */ 32 | -------------------------------------------------------------------------------- /c-ares/inet_ntop.h: -------------------------------------------------------------------------------- 1 | #ifndef __ARES_INET_NTOP_H 2 | #define __ARES_INET_NTOP_H 3 | 4 | 5 | /* Copyright (C) 2005 by Dominick Meglio 6 | * 7 | * Permission to use, copy, modify, and distribute this 8 | * software and its documentation for any purpose and without 9 | * fee is hereby granted, provided that the above copyright 10 | * notice appear in all copies and that both that copyright 11 | * notice and this permission notice appear in supporting 12 | * documentation, and that the name of M.I.T. not be used in 13 | * advertising or publicity pertaining to distribution of the 14 | * software without specific, written prior permission. 15 | * M.I.T. makes no representations about the suitability of 16 | * this software for any purpose. It is provided "as is" 17 | * without express or implied warranty. 18 | */ 19 | 20 | #ifdef HAVE_INET_NTOP 21 | #define ares_inet_ntop(w,x,y,z) inet_ntop(w,x,y,z) 22 | #else 23 | const char *ares_inet_ntop(int af, const void *src, char *dst, size_t size); 24 | #endif 25 | 26 | #endif /* __ARES_INET_NTOP_H */ 27 | -------------------------------------------------------------------------------- /c-ares/windows_port.c: -------------------------------------------------------------------------------- 1 | #include "ares_setup.h" 2 | 3 | 4 | /* only do the following on windows 5 | */ 6 | #if (defined(WIN32) || defined(WATT32)) && !defined(MSDOS) 7 | 8 | #ifdef __WATCOMC__ 9 | /* 10 | * Watcom needs a DllMain() in order to initialise the clib startup code. 11 | */ 12 | BOOL 13 | WINAPI DllMain (HINSTANCE hnd, DWORD reason, LPVOID reserved) 14 | { 15 | (void) hnd; 16 | (void) reason; 17 | (void) reserved; 18 | return (TRUE); 19 | } 20 | #endif 21 | 22 | #endif /* WIN32 builds only */ 23 | -------------------------------------------------------------------------------- /doc/_templates/layout.html: -------------------------------------------------------------------------------- 1 | {% extends "!layout.html" %} 2 | {%- block rootrellink %} 3 |
  • Home{{ reldelim1 }}
  • 4 | {{ super() }} 5 | {%- endblock %} 6 | -------------------------------------------------------------------------------- /doc/community.rst: -------------------------------------------------------------------------------- 1 | Community 2 | ========= 3 | 4 | The official mailing list is hosted on `Google Groups (gevent)`_. To subscribe via email, send a message to gevent+subscribe@googlegroups.com 5 | 6 | You're also welcome to join `#gevent`_ IRC channel on freenode. 7 | 8 | 9 | Russian group 10 | ------------- 11 | 12 | Русскоязычная группа находится здесь: `Google Groups (gevent-ru)`_. Чтобы подписаться, отправьте сообщение на gevent-ru+subscribe@googlegroups.com 13 | 14 | 15 | .. _Google Groups (gevent): http://groups.google.com/group/gevent 16 | .. _#gevent: http://webchat.freenode.net/?channels=gevent 17 | .. _Google Groups (gevent-ru): http://groups.google.com/group/gevent-ru 18 | -------------------------------------------------------------------------------- /doc/contents.rst: -------------------------------------------------------------------------------- 1 | Table Of Contents 2 | ================= 3 | 4 | .. toctree:: 5 | 6 | intro 7 | reference 8 | whatsnew_1_0 9 | changelog 10 | 11 | * :ref:`genindex` 12 | * :ref:`modindex` 13 | * :ref:`search` 14 | 15 | -------------------------------------------------------------------------------- /doc/gevent.core.rst: -------------------------------------------------------------------------------- 1 | :mod:`gevent.core` - event loop based on libev 2 | ============================================== 3 | 4 | .. automodule:: gevent.core 5 | 6 | 7 | This module is a wrapper around libev__ and follower the libev API pretty closely. Note, 8 | that gevent creates an event loop transparently for the user and runs it in a dedicated 9 | greenlet (called hub), so using this module is not necessary. In fact, if you do use it, 10 | chances are that your program is not compatible across different gevent version (gevent.core in 11 | 0.x has a completely different interface and 2.x will probably have yet another interface). 12 | 13 | On Windows, this wrapper will accept Windows handles rather than stdio file descriptors which libev requires. This is to simplify 14 | interaction with the rest of the Python, since it requires Windows handles. 15 | 16 | The current event loop can be obtained with ``gevent.get_hub().loop``. 17 | 18 | 19 | __ http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod 20 | 21 | 22 | events 23 | ------ 24 | 25 | .. autoclass:: loop(flags=None, default=True) 26 | :members: 27 | :undoc-members: 28 | 29 | 30 | misc functions 31 | -------------- 32 | 33 | .. autofunction:: get_version 34 | .. autofunction:: get_header_version 35 | .. autofunction:: supported_backends 36 | .. autofunction:: recommended_backends 37 | .. autofunction:: embeddable_backends 38 | .. autofunction:: time 39 | 40 | -------------------------------------------------------------------------------- /doc/gevent.event.rst: -------------------------------------------------------------------------------- 1 | :mod:`gevent.event` -- Notifications of multiple listeners 2 | ========================================================== 3 | 4 | .. module:: gevent.event 5 | 6 | .. autoclass:: gevent.event.Event 7 | :members: set, clear, wait, rawlink, unlink 8 | 9 | .. method:: is_set() 10 | isSet() 11 | 12 | Return true if and only if the internal flag is true. 13 | 14 | 15 | .. autoclass:: gevent.event.AsyncResult 16 | :members: 17 | :undoc-members: 18 | 19 | .. attribute:: value 20 | 21 | Holds the value passed to :meth:`set` if :meth:`set` was called. Otherwise ``None``. 22 | 23 | -------------------------------------------------------------------------------- /doc/gevent.hub.rst: -------------------------------------------------------------------------------- 1 | :mod:`gevent.hub` 2 | ================= 3 | 4 | .. module:: gevent.hub 5 | 6 | .. autoclass:: Hub 7 | :members: 8 | :undoc-members: 9 | 10 | .. autofunction:: get_hub 11 | 12 | .. autoclass:: Waiter 13 | -------------------------------------------------------------------------------- /doc/gevent.queue.rst: -------------------------------------------------------------------------------- 1 | :mod:`gevent.queue` -- Synchronized queues 2 | ========================================== 3 | 4 | .. automodule:: gevent.queue 5 | :members: 6 | :undoc-members: 7 | 8 | .. exception:: Full 9 | 10 | An alias for :class:`Queue.Full` 11 | 12 | .. exception:: Empty 13 | 14 | An alias for :class:`Queue.Empty` 15 | 16 | Example of how to wait for enqueued tasks to be completed:: 17 | 18 | def worker(): 19 | while True: 20 | item = q.get() 21 | try: 22 | do_work(item) 23 | finally: 24 | q.task_done() 25 | 26 | q = JoinableQueue() 27 | for i in range(num_worker_threads): 28 | gevent.spawn(worker) 29 | 30 | for item in source(): 31 | q.put(item) 32 | 33 | q.join() # block until all tasks are done 34 | 35 | -------------------------------------------------------------------------------- /doc/mytheme/changes/frameset.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | {% trans version=version|e, docstitle=docstitle|e %}Changes in Version {{ version }} — {{ docstitle }}{% endtrans %} 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /doc/mytheme/changes/rstsource.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | {% trans filename=filename, docstitle=docstitle|e %}{{ filename }} — {{ docstitle }}{% endtrans %} 6 | 9 | 10 | 11 |
    12 |       {{ text }}
    13 |     
    14 | 15 | 16 | -------------------------------------------------------------------------------- /doc/mytheme/changes/versionchanges.html: -------------------------------------------------------------------------------- 1 | {% macro entries(changes) %} 2 |
      {% for entry, docname, lineno in changes %} 3 |
    • {{ entry }}
    • 4 | {% endfor %}
    5 | {% endmacro -%} 6 | 8 | 9 | 10 | 11 | 12 | {% trans version=version|e, docstitle=docstitle|e %}Changes in Version {{ version }} — {{ docstitle }}{% endtrans %} 13 | 14 | 15 |
    16 |
    17 |

    {% trans version=version|e %}Automatically generated list of changes in version {{ version }}{% endtrans %}

    18 |

    {{ _('Library changes') }}

    19 | {% for modname, changes in libchanges %} 20 |

    {{ modname }}

    21 | {{ entries(changes) }} 22 | {% endfor %} 23 |

    {{ _('C API changes') }}

    24 | {{ entries(apichanges) }} 25 |

    {{ _('Other changes') }}

    26 | {% for (fn, title), changes in otherchanges %} 27 |

    {{ title }} ({{ fn }})

    28 | {{ entries(changes) }} 29 | {% endfor %} 30 |
    31 |
    32 | 33 | 34 | -------------------------------------------------------------------------------- /doc/mytheme/defindex.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | {% set title = _('Overview') %} 3 | {% block body %} 4 |

    {{ docstitle|e }}

    5 |

    6 | Welcome! This is 7 | {% block description %}the documentation for {{ project|e }} 8 | {{ release|e }}{% if last_updated %}, last updated {{ last_updated|e }}{% endif %}{% endblock %}. 9 |

    10 | {% block tables %} 11 |

    {{ _('Indices and tables:') }}

    12 | 13 | 24 |
    14 | 16 | 18 | 19 | 21 | 23 |
    25 | {% endblock %} 26 | {% endblock %} 27 | -------------------------------------------------------------------------------- /doc/mytheme/genindex-single.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | {% set title = _('Index') %} 3 | {% block body %} 4 | 5 |

    {% trans key=key %}Index – {{ key }}{% endtrans %}

    6 | 7 |
    8 |
    9 | {%- set breakat = count // 2 %} 10 | {%- set numcols = 1 %} 11 | {%- set numitems = 0 %} 12 | {% for entryname, (links, subitems) in entries %} 13 |
    {%- if links -%}{{ entryname|e }} 14 | {%- for link in links[1:] %}, [{{ loop.index }}]{% endfor -%} 15 | {%- else -%} 16 | {{ entryname|e }} 17 | {%- endif -%}
    18 | {%- if subitems %} 19 |
    20 | {%- for subentryname, subentrylinks in subitems %} 21 |
    {{ subentryname|e }} 22 | {%- for link in subentrylinks[1:] %}, [{{ loop.index }}]{% endfor -%} 23 |
    24 | {%- endfor %} 25 |
    26 | {%- endif -%} 27 | {%- set numitems = numitems + 1 + (subitems|length) -%} 28 | {%- if numcols < 2 and numitems > breakat -%} 29 | {%- set numcols = numcols+1 -%} 30 |
    31 | {%- endif -%} 32 | {%- endfor %} 33 |
    34 | 35 | {% endblock %} 36 | 37 | {% block sidebarrel %} 38 |

    Index

    39 |

    {% for key, dummy in genindexentries -%} 40 | {{ key }} 41 | {% if not loop.last %}| {% endif %} 42 | {%- endfor %}

    43 | 44 |

    {{ _('Full index on one page') }}

    45 | {{ super() }} 46 | {% endblock %} 47 | -------------------------------------------------------------------------------- /doc/mytheme/genindex-split.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | {% set title = _('Index') %} 3 | {% block body %} 4 | 5 |

    {{ _('Index') }}

    6 | 7 |

    {{ _('Index pages by letter') }}:

    8 | 9 |

    {% for key, dummy in genindexentries -%} 10 | {{ key }} 11 | {% if not loop.last %}| {% endif %} 12 | {%- endfor %}

    13 | 14 |

    {{ _('Full index on one page') }} 15 | ({{ _('can be huge') }})

    16 | 17 | {% endblock %} 18 | 19 | {% block sidebarrel %} 20 | {% if split_index %} 21 |

    Index

    22 |

    {% for key, dummy in genindexentries -%} 23 | {{ key }} 24 | {% if not loop.last %}| {% endif %} 25 | {%- endfor %}

    26 | 27 |

    {{ _('Full index on one page') }}

    28 | {% endif %} 29 | {{ super() }} 30 | {% endblock %} 31 | -------------------------------------------------------------------------------- /doc/mytheme/genindex.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | {% set title = _('Index') %} 3 | {% block body %} 4 | 5 |

    {{ _('Index') }}

    6 | 7 | {% for key, dummy in genindexentries -%} 8 | {{ key }} {% if not loop.last %}| {% endif %} 9 | {%- endfor %} 10 | 11 |
    12 | 13 | {% for key, entries in genindexentries %} 14 |

    {{ key }}

    15 |
    16 |
    17 | {%- set breakat = genindexcounts[loop.index0] // 2 %} 18 | {%- set numcols = 1 %} 19 | {%- set numitems = 0 %} 20 | {% for entryname, (links, subitems) in entries %} 21 |
    {%- if links -%}{{ entryname|e }} 22 | {%- for link in links[1:] %}, [{{ loop.index }}]{% endfor -%} 23 | {%- else -%} 24 | {{ entryname|e }} 25 | {%- endif -%}
    26 | {%- if subitems %} 27 |
    28 | {%- for subentryname, subentrylinks in subitems %} 29 |
    {{ subentryname|e }} 30 | {%- for link in subentrylinks[1:] %}, [{{ loop.index }}]{% endfor -%} 31 |
    32 | {%- endfor %} 33 |
    34 | {%- endif -%} 35 | {%- set numitems = numitems + 1 + (subitems|length) -%} 36 | {%- if numcols < 2 and numitems > breakat -%} 37 | {%- set numcols = numcols+1 -%} 38 |
    39 | {%- endif -%} 40 | {%- endfor %} 41 |
    42 | {% endfor %} 43 | 44 | {% endblock %} 45 | 46 | {% block sidebarrel %} 47 | {% if split_index %} 48 |

    {{ _('Index') }}

    49 |

    {% for key, dummy in genindexentries -%} 50 | {{ key }} 51 | {% if not loop.last %}| {% endif %} 52 | {%- endfor %}

    53 | 54 |

    {{ _('Full index on one page') }}

    55 | {% endif %} 56 | {{ super() }} 57 | {% endblock %} 58 | -------------------------------------------------------------------------------- /doc/mytheme/modindex.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | {% set title = _('Global Module Index') %} 3 | {% block extrahead %} 4 | {{ super() }} 5 | {% if not embedded and collapse_modindex %} 6 | 9 | {% endif %} 10 | {% endblock %} 11 | {% block body %} 12 | 13 |

    {{ _('Global Module Index') }}

    14 | 15 | {%- for letter in letters %} 16 | {{ letter }} {% if not loop.last %}| {% endif %} 17 | {%- endfor %} 18 |
    19 | 20 | 21 | {%- for modname, collapse, cgroup, indent, fname, synops, pform, dep, stripped in modindexentries %} 22 | {%- if not modname -%} 23 | 24 | 25 | {%- else -%} 26 | 27 | 31 | 38 | {%- endif -%} 39 | {% endfor %} 40 |
     
    {{ fname }}
    {% if collapse -%} 28 | 30 | {%- endif %}{% if indent %}   {% endif %} 32 | {% if fname %}{% endif -%} 33 | {{ stripped|e }}{{ modname|e }} 34 | {%- if fname %}{% endif %} 35 | {%- if pform and pform[0] %} ({{ pform|join(', ') }}){% endif -%} 36 | {% if dep %}{{ _('Deprecated')}}:{% endif %} 37 | {{ synops|e }}
    41 | 42 | {% endblock %} 43 | -------------------------------------------------------------------------------- /doc/mytheme/page.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | {% block body %} 3 | {{ body }} 4 | {% endblock %} 5 | -------------------------------------------------------------------------------- /doc/mytheme/search.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | {% set title = _('Search') %} 3 | {% set script_files = script_files + ['_static/searchtools.js'] %} 4 | {% block body %} 5 |

    {{ _('Search') }}

    6 |
    7 | 8 |

    9 | {% trans %}Please activate JavaScript to enable the search 10 | functionality.{% endtrans %} 11 |

    12 |
    13 |

    14 | {% trans %}From here you can search these documents. Enter your search 15 | words into the box below and click "search". Note that the search 16 | function will automatically search for all of the words. Pages 17 | containing fewer words won't appear in the result list.{% endtrans %} 18 |

    19 |
    20 | 21 | 22 | 23 |
    24 | {% if search_performed %} 25 |

    {{ _('Search Results') }}

    26 | {% if not search_results %} 27 |

    {{ _('Your search did not match any results.') }}

    28 | {% endif %} 29 | {% endif %} 30 |
    31 | {% if search_results %} 32 |
      33 | {% for href, caption, context in search_results %} 34 |
    • {{ caption }} 35 |
      {{ context|e }}
      36 |
    • 37 | {% endfor %} 38 |
    39 | {% endif %} 40 |
    41 | {% endblock %} 42 | {% block footer %} 43 | {{ super() }} 44 | 45 | {% endblock %} 46 | -------------------------------------------------------------------------------- /doc/mytheme/static/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantix/gevent/71dd2d4d1d3332ed87f79c19d54d97bdcacdcf6d/doc/mytheme/static/file.png -------------------------------------------------------------------------------- /doc/mytheme/static/img/main-two-columns.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantix/gevent/71dd2d4d1d3332ed87f79c19d54d97bdcacdcf6d/doc/mytheme/static/img/main-two-columns.gif -------------------------------------------------------------------------------- /doc/mytheme/static/minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantix/gevent/71dd2d4d1d3332ed87f79c19d54d97bdcacdcf6d/doc/mytheme/static/minus.png -------------------------------------------------------------------------------- /doc/mytheme/static/omegle_48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantix/gevent/71dd2d4d1d3332ed87f79c19d54d97bdcacdcf6d/doc/mytheme/static/omegle_48.png -------------------------------------------------------------------------------- /doc/mytheme/static/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantix/gevent/71dd2d4d1d3332ed87f79c19d54d97bdcacdcf6d/doc/mytheme/static/plus.png -------------------------------------------------------------------------------- /doc/mytheme/static/spotify_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantix/gevent/71dd2d4d1d3332ed87f79c19d54d97bdcacdcf6d/doc/mytheme/static/spotify_logo.png -------------------------------------------------------------------------------- /doc/mytheme/static/transparent.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantix/gevent/71dd2d4d1d3332ed87f79c19d54d97bdcacdcf6d/doc/mytheme/static/transparent.gif -------------------------------------------------------------------------------- /doc/mytheme/theme.conf: -------------------------------------------------------------------------------- 1 | [theme] 2 | inherit = none 3 | stylesheet = basic.css 4 | pygments_style = sphinx 5 | 6 | [options] 7 | nosidebar = false 8 | rightsidebar = false 9 | stickysidebar = false 10 | 11 | footerbgcolor = #11303d 12 | footertextcolor = #ffffff 13 | sidebarbgcolor = #1c4e63 14 | sidebartextcolor = #ffffff 15 | sidebarlinkcolor = #98dbcc 16 | relbarbgcolor = #133f52 17 | relbartextcolor = #ffffff 18 | relbarlinkcolor = #ffffff 19 | bgcolor = #ffffff 20 | textcolor = #000000 21 | headbgcolor = #f2f2f2 22 | headtextcolor = #20435c 23 | headlinkcolor = #c60f0f 24 | linkcolor = #355f7c 25 | codebgcolor = #eeffcc 26 | codetextcolor = #333333 27 | 28 | bodyfont = sans-serif 29 | headfont = 'Trebuchet MS', sans-serif 30 | -------------------------------------------------------------------------------- /doc/networking.rst: -------------------------------------------------------------------------------- 1 | Networking interfaces 2 | --------------------- 3 | 4 | .. toctree:: 5 | 6 | gevent.socket 7 | gevent.ssl 8 | gevent.select 9 | -------------------------------------------------------------------------------- /doc/reference.rst: -------------------------------------------------------------------------------- 1 | API reference 2 | ------------- 3 | 4 | .. toctree:: 5 | 6 | gevent 7 | networking 8 | synchronization 9 | gevent.pool 10 | servers 11 | gevent.local 12 | gevent.monkey 13 | gevent.core 14 | gevent.backdoor 15 | -------------------------------------------------------------------------------- /doc/synchronization.rst: -------------------------------------------------------------------------------- 1 | Synchronization primitives 2 | -------------------------- 3 | 4 | .. toctree:: 5 | 6 | gevent.event 7 | gevent.queue 8 | gevent.lock 9 | 10 | -------------------------------------------------------------------------------- /examples/concurrent_download.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # Copyright (c) 2009 Denis Bilenko. See LICENSE for details. 3 | 4 | """Spawn multiple workers and wait for them to complete""" 5 | from __future__ import print_function 6 | import sys 7 | 8 | urls = ['http://www.google.com', 'http://www.yandex.ru', 'http://www.python.org'] 9 | 10 | import gevent 11 | from gevent import monkey 12 | 13 | # patches stdlib (including socket and ssl modules) to cooperate with other greenlets 14 | monkey.patch_all() 15 | 16 | 17 | if sys.version_info[0] == 3: 18 | from urllib.request import urlopen 19 | else: 20 | from urllib2 import urlopen 21 | 22 | 23 | def print_head(url): 24 | print('Starting %s' % url) 25 | data = urlopen(url).read() 26 | print('%s: %s bytes: %r' % (url, len(data), data[:50])) 27 | 28 | jobs = [gevent.spawn(print_head, url) for url in urls] 29 | 30 | gevent.wait(jobs) 31 | -------------------------------------------------------------------------------- /examples/dns_mass_resolve.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | """Resolve hostnames concurrently, exit after 2 seconds. 3 | 4 | Under the hood, this might use an asynchronous resolver based on 5 | c-ares (the default) or thread-pool-based resolver. 6 | 7 | You can choose between resolvers using GEVENT_RESOLVER environment 8 | variable. To enable threading resolver: 9 | 10 | GEVENT_RESOLVER=thread python dns_mass_resolve.py 11 | """ 12 | from __future__ import print_function 13 | import gevent 14 | from gevent import socket 15 | from gevent.pool import Pool 16 | 17 | N = 1000 18 | # limit ourselves to max 10 simultaneous outstanding requests 19 | pool = Pool(10) 20 | finished = 0 21 | 22 | 23 | def job(url): 24 | global finished 25 | try: 26 | try: 27 | ip = socket.gethostbyname(url) 28 | print('%s = %s' % (url, ip)) 29 | except socket.gaierror as ex: 30 | print('%s failed with %s' % (url, ex)) 31 | finally: 32 | finished += 1 33 | 34 | with gevent.Timeout(2, False): 35 | for x in range(10, 10 + N): 36 | pool.spawn(job, '%s.com' % x) 37 | pool.join() 38 | 39 | print('finished within 2 seconds: %s/%s' % (finished, N)) 40 | -------------------------------------------------------------------------------- /examples/echoserver.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Simple server that listens on port 6000 and echos back every input to the client. 3 | 4 | Connect to it with: 5 | telnet localhost 6000 6 | 7 | Terminate the connection by terminating telnet (typically Ctrl-] and then 'quit'). 8 | """ 9 | from __future__ import print_function 10 | from gevent.server import StreamServer 11 | 12 | 13 | # this handler will be run for each incoming connection in a dedicated greenlet 14 | def echo(socket, address): 15 | print('New connection from %s:%s' % address) 16 | socket.sendall(b'Welcome to the echo server! Type quit to exit.\r\n') 17 | # using a makefile because we want to use readline() 18 | fileobj = socket.makefile('rwb') 19 | while True: 20 | line = fileobj.readline() 21 | if not line: 22 | print("client disconnected") 23 | break 24 | if line.strip().lower() == b'quit': 25 | print("client quit") 26 | break 27 | fileobj.write(line) 28 | fileobj.flush() 29 | print("echoed %r" % line) 30 | 31 | 32 | if __name__ == '__main__': 33 | # to make the server use SSL, pass certfile and keyfile arguments to the constructor 34 | server = StreamServer(('0.0.0.0', 6000), echo) 35 | # to start the server asynchronously, use its start() method; 36 | # we use blocking serve_forever() here because we have no other jobs 37 | print('Starting echo server on port 6000') 38 | server.serve_forever() 39 | -------------------------------------------------------------------------------- /examples/geventsendfile.py: -------------------------------------------------------------------------------- 1 | """An example how to use sendfile[1] with gevent. 2 | 3 | [1] http://pypi.python.org/pypi/py-sendfile/ 4 | """ 5 | from errno import EAGAIN 6 | from sendfile import sendfile as original_sendfile 7 | from gevent.socket import wait_write 8 | 9 | 10 | def gevent_sendfile(out_fd, in_fd, offset, count): 11 | total_sent = 0 12 | while total_sent < count: 13 | try: 14 | _offset, sent = original_sendfile(out_fd, in_fd, offset + total_sent, count - total_sent) 15 | #print('%s: sent %s [%d%%]' % (out_fd, sent, 100*total_sent/count)) 16 | total_sent += sent 17 | except OSError as ex: 18 | if ex.args[0] == EAGAIN: 19 | wait_write(out_fd) 20 | else: 21 | raise 22 | return offset + total_sent, total_sent 23 | 24 | 25 | def patch_sendfile(): 26 | import sendfile 27 | sendfile.sendfile = gevent_sendfile 28 | -------------------------------------------------------------------------------- /examples/processes.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from __future__ import print_function 3 | import gevent 4 | from gevent import subprocess 5 | 6 | 7 | # run 2 jobs in parallel 8 | p1 = subprocess.Popen(['uname'], stdout=subprocess.PIPE) 9 | p2 = subprocess.Popen(['ls'], stdout=subprocess.PIPE) 10 | 11 | gevent.wait([p1, p2], timeout=2) 12 | 13 | # print the results (if available) 14 | if p1.poll() is not None: 15 | print('uname: %r' % p1.stdout.read()) 16 | else: 17 | print('uname: job is still running') 18 | if p2.poll() is not None: 19 | print('ls: %r' % p2.stdout.read()) 20 | else: 21 | print('ls: job is still running') 22 | -------------------------------------------------------------------------------- /examples/server.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICYzCCAcwCCQD5jx1Aa0dytjANBgkqhkiG9w0BAQQFADB2MQswCQYDVQQGEwJU 3 | UzENMAsGA1UECBMEVGVzdDENMAsGA1UEBxMEVGVzdDEWMBQGA1UEChMNVGVzdCBF 4 | dmVudGxldDENMAsGA1UECxMEVGVzdDENMAsGA1UEAxMEVGVzdDETMBEGCSqGSIb3 5 | DQEJARYEVGVzdDAeFw0wODA3MDgyMTExNDJaFw0xMDAyMDgwODE1MTBaMHYxCzAJ 6 | BgNVBAYTAlRTMQ0wCwYDVQQIEwRUZXN0MQ0wCwYDVQQHEwRUZXN0MRYwFAYDVQQK 7 | Ew1UZXN0IEV2ZW50bGV0MQ0wCwYDVQQLEwRUZXN0MQ0wCwYDVQQDEwRUZXN0MRMw 8 | EQYJKoZIhvcNAQkBFgRUZXN0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDM 9 | WcyeIiHQuEGQxgTIvu0aOW4iRFAyUEi8pLWNCxMEHglF8k6OxFVq7XWZMDnDFVnb 10 | ZjmQh5Tc21Ae6cXzxXln578fROXHEzXo3Is8HUlq3ug1yYOGHjxw++Opjf1uoHwP 11 | EBUKsz/flS7knuscgFM9FO05KSPn2wHnZeIDta4yTwIDAQABMA0GCSqGSIb3DQEB 12 | BAUAA4GBAKM71aP0r26gEEEBzovfXm1IwKav6R9/xiWsJ4pFsUXVotcaIjcVBDG1 13 | Z7tz688hokb+GNxsTI2gNfqanqUnfP9wZxnKRmfTSOvb5aWHIiaiMXSgjiPlqBcm 14 | 6mnSeEbSMM9cw479wWhh1YqY8tf3gYJa+sxznVWLSfVLpsjRMphe 15 | -----END CERTIFICATE----- 16 | -------------------------------------------------------------------------------- /examples/server.key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXgIBAAKBgQDMWcyeIiHQuEGQxgTIvu0aOW4iRFAyUEi8pLWNCxMEHglF8k6O 3 | xFVq7XWZMDnDFVnbZjmQh5Tc21Ae6cXzxXln578fROXHEzXo3Is8HUlq3ug1yYOG 4 | Hjxw++Opjf1uoHwPEBUKsz/flS7knuscgFM9FO05KSPn2wHnZeIDta4yTwIDAQAB 5 | AoGBAKWfvq0IIvok7Ncm92ew/0D6/R1+2rT8xwdGQ/Nt31q98WwkqLEjxctlbKPd 6 | J2PLIUomf0955BhhFH4JoSwjiHJQ6uishY7srjQQDX/Dxdi5wZAyxYCIVW/kAA9N 7 | /u2s75hSD3s/rqAwOZ182DwAPIqJc4KQoYzvlKERSMDT1PJhAkEA5SUFsiSzBEMX 8 | FyZ++ZMMs1vHrTu5oTK7WHznh9lk7dvsnp9BoUPqhiu8iJ7Q23zj0u5asz2czu11 9 | nnczXgU6XwJBAORM5Ib4I7nAsoUWn9wDiTwVQeE+D9P1ac9p7EHm7XXuf8o2irRZ 10 | wYYfpXXsjk496YfyQFcQRMk0tU0gegCP7hECQFWRWqwoajUoPIInnPjjwbVki48U 11 | I4CfqjgkBG3Fb5wnKRgezmpDK1vJD1FRRRsBay4EVhhi5KCdKfPv/V2ZxC8CQQCu 12 | U5SxBytofJ8UhxkcTErvaR/8GYLGi//21GAGVop+YdaMlydE3cCrZODYcgCb+CSp 13 | nS7KDG8p4KiMMz9VzJGxAkEAv85K6Sa3H8g9h7LwopBZ5tFNZUaFWo7lEP7DDMH0 14 | eckZTb1JVpyT/8zrDtsis4WlV9zVkVHxkIaad503BjqvEQ== 15 | -----END RSA PRIVATE KEY----- 16 | -------------------------------------------------------------------------------- /examples/threadpool.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | import time 3 | import gevent 4 | from gevent.threadpool import ThreadPool 5 | 6 | 7 | pool = ThreadPool(3) 8 | start = time.time() 9 | for _ in range(4): 10 | pool.spawn(time.sleep, 1) 11 | gevent.wait() 12 | delay = time.time() - start 13 | print('Running "time.sleep(1)" 4 times with 3 threads. Should take about 2 seconds: %.3fs' % delay) 14 | -------------------------------------------------------------------------------- /examples/udp_client.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2012 Denis Bilenko. See LICENSE for details. 2 | """Send a datagram to localhost:9000 and receive a datagram back. 3 | 4 | Usage: python udp_client.py MESSAGE 5 | 6 | Make sure you're running a UDP server on port 9000 (see udp_server.py). 7 | 8 | There's nothing gevent-specific here. 9 | """ 10 | from __future__ import print_function 11 | import sys 12 | from gevent import socket 13 | 14 | address = ('localhost', 9000) 15 | message = ' '.join(sys.argv[1:]) 16 | sock = socket.socket(type=socket.SOCK_DGRAM) 17 | sock.connect(address) 18 | print('Sending %s bytes to %s:%s' % ((len(message), ) + address)) 19 | sock.send(message.encode()) 20 | data, address = sock.recvfrom(8192) 21 | print('%s:%s: got %r' % (address + (data, ))) 22 | -------------------------------------------------------------------------------- /examples/udp_server.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2012 Denis Bilenko. See LICENSE for details. 2 | """A simple UDP server. 3 | 4 | For every message received, it sends a reply back. 5 | 6 | You can use udp_client.py to send a message. 7 | """ 8 | from __future__ import print_function 9 | from gevent.server import DatagramServer 10 | 11 | 12 | class EchoServer(DatagramServer): 13 | 14 | def handle(self, data, address): 15 | print('%s: got %r' % (address[0], data)) 16 | self.socket.sendto(('Received %s bytes' % len(data)).encode(), address) 17 | 18 | 19 | if __name__ == '__main__': 20 | print('Receiving datagrams on :9000') 21 | EchoServer(':9000').serve_forever() 22 | -------------------------------------------------------------------------------- /examples/unixsocket_client.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | import socket 3 | 4 | s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 5 | s.connect("./unixsocket_server.py.sock") 6 | s.send('GET / HTTP/1.0\r\n\r\n') 7 | data = s.recv(1024) 8 | print('received %s bytes' % len(data)) 9 | print(data) 10 | s.close() 11 | -------------------------------------------------------------------------------- /examples/unixsocket_server.py: -------------------------------------------------------------------------------- 1 | import os 2 | from gevent.pywsgi import WSGIServer 3 | from gevent import socket 4 | 5 | 6 | def application(environ, start_response): 7 | start_response('200 OK', []) 8 | return [] 9 | 10 | 11 | if __name__ == '__main__': 12 | listener = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 13 | sockname = './' + os.path.basename(__file__) + '.sock' 14 | if os.path.exists(sockname): 15 | os.remove(sockname) 16 | listener.bind(sockname) 17 | listener.listen(1) 18 | WSGIServer(listener, application).serve_forever() 19 | -------------------------------------------------------------------------------- /examples/webchat/README: -------------------------------------------------------------------------------- 1 | An example of AJAX chat taken from Tornado demos and converted to use django and gevent. 2 | 3 | To start the server, run 4 | $ python run.py 5 | -------------------------------------------------------------------------------- /examples/webchat/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantix/gevent/71dd2d4d1d3332ed87f79c19d54d97bdcacdcf6d/examples/webchat/__init__.py -------------------------------------------------------------------------------- /examples/webchat/application.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | from gevent import monkey; monkey.patch_all() 3 | import os 4 | import traceback 5 | from django.core.handlers.wsgi import WSGIHandler 6 | from django.core.signals import got_request_exception 7 | from django.core.management import call_command 8 | 9 | os.environ['DJANGO_SETTINGS_MODULE'] = 'webchat.settings' 10 | 11 | 12 | def exception_printer(sender, **kwargs): 13 | traceback.print_exc() 14 | 15 | 16 | got_request_exception.connect(exception_printer) 17 | 18 | call_command('syncdb') 19 | 20 | application = WSGIHandler() 21 | -------------------------------------------------------------------------------- /examples/webchat/chat/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantix/gevent/71dd2d4d1d3332ed87f79c19d54d97bdcacdcf6d/examples/webchat/chat/__init__.py -------------------------------------------------------------------------------- /examples/webchat/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | from django.core.management import execute_manager 3 | try: 4 | import settings # Assumed to be in the same directory. 5 | except ImportError: 6 | import sys 7 | sys.stderr.write("""Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things. 8 | You'll have to run django-admin.py, passing it your settings module. 9 | (If the file settings.py does indeed exist, it's causing an ImportError somehow.) 10 | """ % __file__) 11 | raise 12 | 13 | if __name__ == "__main__": 14 | execute_manager(settings) 15 | -------------------------------------------------------------------------------- /examples/webchat/run_standalone.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | from __future__ import print_function 3 | from gevent.wsgi import WSGIServer 4 | from application import application 5 | print('Serving on 8000...') 6 | WSGIServer(('', 8000), application).serve_forever() 7 | -------------------------------------------------------------------------------- /examples/webchat/run_uwsgi: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # see http://projects.unbit.it/uwsgi and http://projects.unbit.it/uwsgi/wiki/Gevent 3 | exec uwsgi --loop gevent --http-socket :8000 --module application --async 1000 4 | -------------------------------------------------------------------------------- /examples/webchat/settings.py: -------------------------------------------------------------------------------- 1 | from os.path import dirname, join, abspath 2 | __dir__ = dirname(abspath(__file__)) 3 | 4 | DEBUG = True 5 | TEMPLATE_DEBUG = DEBUG 6 | ADMINS = () 7 | MANAGERS = ADMINS 8 | DATABASE_ENGINE = 'sqlite3' 9 | DATABASE_NAME = '/tmp/gevent-webchat.sqlite' 10 | DATABASE_USER = '' 11 | DATABASE_PASSWORD = '' 12 | DATABASE_HOST = '' 13 | DATABASE_PORT = '' 14 | TIME_ZONE = 'America/Chicago' 15 | LANGUAGE_CODE = 'en-us' 16 | SITE_ID = 1 17 | USE_I18N = True 18 | MEDIA_ROOT = join(__dir__, 'static') 19 | MEDIA_URL = '/media/' 20 | SECRET_KEY = 'nv8(yg*&1-lon-8i-3jcs0y!01+rem*54051^5xt#^tzujdj!c' 21 | TEMPLATE_LOADERS = ( 22 | 'django.template.loaders.filesystem.load_template_source', 23 | 'django.template.loaders.app_directories.load_template_source', 24 | ) 25 | MIDDLEWARE_CLASSES = ( 26 | 'django.middleware.common.CommonMiddleware', 27 | 'django.contrib.sessions.middleware.SessionMiddleware', 28 | ) 29 | ROOT_URLCONF = 'webchat.urls' 30 | TEMPLATE_DIRS = ( 31 | join(__dir__, 'templates') 32 | ) 33 | INSTALLED_APPS = ( 34 | 'django.contrib.contenttypes', 35 | 'django.contrib.sessions', 36 | 'django.contrib.sites', 37 | 'webchat.chat', 38 | ) 39 | -------------------------------------------------------------------------------- /examples/webchat/static/chat.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009 FriendFeed 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | * not use this file except in compliance with the License. You may obtain 6 | * a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | body { 18 | background: white; 19 | margin: 10px; 20 | } 21 | 22 | body, 23 | input { 24 | font-family: sans-serif; 25 | font-size: 10pt; 26 | color: black; 27 | } 28 | 29 | table { 30 | border-collapse: collapse; 31 | border: 0; 32 | } 33 | 34 | td { 35 | border: 0; 36 | padding: 0; 37 | } 38 | 39 | #body { 40 | position: absolute; 41 | bottom: 10px; 42 | left: 10px; 43 | right: 100px; 44 | } 45 | 46 | #input { 47 | margin-top: 0.5em; 48 | } 49 | 50 | #inbox .message { 51 | padding-top: 0.25em; 52 | } 53 | 54 | #nav { 55 | text-align: right; 56 | float: right; 57 | z-index: 99; 58 | } 59 | -------------------------------------------------------------------------------- /examples/webchat/templates/404.html: -------------------------------------------------------------------------------- 1 |

    Not Found

    2 | -------------------------------------------------------------------------------- /examples/webchat/templates/500.html: -------------------------------------------------------------------------------- 1 |

    Internal Server Error

    2 | -------------------------------------------------------------------------------- /examples/webchat/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Chat Demo 6 | 7 | 8 | 9 | 13 |
    14 |
    15 | {% for message in messages %} 16 | {% include "message.html" %} 17 | {% endfor %} 18 |
    19 |
    20 |
    21 | 22 | 23 | 24 | 28 | 29 |
    25 | 26 | 27 |
    30 |
    31 |
    32 |
    33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /examples/webchat/templates/message.html: -------------------------------------------------------------------------------- 1 |
    {{ message.from }}: {{ message.body }}
    2 | -------------------------------------------------------------------------------- /examples/webchat/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls.defaults import * 2 | from webchat import settings 3 | 4 | urlpatterns = patterns('webchat.chat.views', 5 | ('^$', 'main'), 6 | ('^a/message/new$', 'message_new'), 7 | ('^a/message/updates$', 'message_updates')) 8 | 9 | urlpatterns += patterns('django.views.static', 10 | (r'^%s(?P.*)$' % settings.MEDIA_URL.lstrip('/'), 'serve', 11 | {'document_root': settings.MEDIA_ROOT, 12 | 'show_indexes': True})) 13 | -------------------------------------------------------------------------------- /examples/webpy.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | """A web.py application powered by gevent""" 3 | 4 | from __future__ import print_function 5 | from gevent import monkey; monkey.patch_all() 6 | from gevent.pywsgi import WSGIServer 7 | import time 8 | import web 9 | 10 | urls = ("/", "index", 11 | '/long', 'long_polling') 12 | 13 | 14 | class index: 15 | def GET(self): 16 | return 'Hello, world!
    /long' 17 | 18 | 19 | class long_polling: 20 | # Since gevent's WSGIServer executes each incoming connection in a separate greenlet 21 | # long running requests such as this one don't block one another; 22 | # and thanks to "monkey.patch_all()" statement at the top, thread-local storage used by web.ctx 23 | # becomes greenlet-local storage thus making requests isolated as they should be. 24 | def GET(self): 25 | print('GET /long') 26 | time.sleep(10) # possible to block the request indefinitely, without harming others 27 | return 'Hello, 10 seconds later' 28 | 29 | 30 | if __name__ == "__main__": 31 | application = web.application(urls, globals()).wsgifunc() 32 | print('Serving on 8088...') 33 | WSGIServer(('', 8088), application).serve_forever() 34 | -------------------------------------------------------------------------------- /examples/wsgiserver.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | """WSGI server example""" 3 | from __future__ import print_function 4 | from gevent.pywsgi import WSGIServer 5 | 6 | 7 | def application(env, start_response): 8 | if env['PATH_INFO'] == '/': 9 | start_response('200 OK', [('Content-Type', 'text/html')]) 10 | return [b"hello world"] 11 | else: 12 | start_response('404 Not Found', [('Content-Type', 'text/html')]) 13 | return [b'

    Not Found

    '] 14 | 15 | 16 | if __name__ == '__main__': 17 | print('Serving on 8088...') 18 | WSGIServer(('', 8088), application).serve_forever() 19 | -------------------------------------------------------------------------------- /examples/wsgiserver_ssl.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | """Secure WSGI server example based on gevent.pywsgi""" 3 | 4 | from __future__ import print_function 5 | from gevent import pywsgi 6 | 7 | 8 | def hello_world(env, start_response): 9 | if env['PATH_INFO'] == '/': 10 | start_response('200 OK', [('Content-Type', 'text/html')]) 11 | return [b"hello world"] 12 | else: 13 | start_response('404 Not Found', [('Content-Type', 'text/html')]) 14 | return [b'

    Not Found

    '] 15 | 16 | print('Serving on https://127.0.0.1:8443') 17 | server = pywsgi.WSGIServer(('0.0.0.0', 8443), hello_world, keyfile='server.key', certfile='server.crt') 18 | # to start the server asynchronously, call server.start() 19 | # we use blocking serve_forever() here because we have no other jobs 20 | server.serve_forever() 21 | -------------------------------------------------------------------------------- /gevent/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details. 2 | """ 3 | gevent is a coroutine-based Python networking library that uses greenlet 4 | to provide a high-level synchronous API on top of libev event loop. 5 | 6 | See http://www.gevent.org/ for the documentation. 7 | """ 8 | 9 | from __future__ import absolute_import 10 | 11 | version_info = (1, 1, 0, 'dev', None) 12 | __version__ = '1.1' 13 | 14 | 15 | __all__ = ['get_hub', 16 | 'Greenlet', 17 | 'GreenletExit', 18 | 'spawn', 19 | 'spawn_later', 20 | 'spawn_raw', 21 | 'iwait', 22 | 'wait', 23 | 'killall', 24 | 'Timeout', 25 | 'with_timeout', 26 | 'getcurrent', 27 | 'sleep', 28 | 'idle', 29 | 'kill', 30 | 'signal', 31 | 'fork', 32 | 'reinit'] 33 | 34 | 35 | from gevent.hub import get_hub, iwait, wait, PYPY 36 | from gevent.greenlet import Greenlet, joinall, killall 37 | spawn = Greenlet.spawn 38 | spawn_later = Greenlet.spawn_later 39 | from gevent.timeout import Timeout, with_timeout 40 | from gevent.hub import getcurrent, GreenletExit, spawn_raw, sleep, idle, kill, signal, reinit 41 | try: 42 | from gevent.os import fork 43 | except ImportError: 44 | __all__.remove('fork') 45 | 46 | 47 | # the following makes hidden imports visible to freezing tools like 48 | # py2exe. see https://github.com/surfly/gevent/issues/181 49 | def __dependencies_for_freezing(): 50 | from gevent import core, resolver_thread, resolver_ares, socket,\ 51 | threadpool, thread, threading, select, subprocess 52 | import pprint 53 | import traceback 54 | import signal 55 | 56 | del __dependencies_for_freezing 57 | -------------------------------------------------------------------------------- /gevent/_fileobjectcommon.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from gevent._socketcommon import EBADF 3 | 4 | 5 | cancel_wait_ex = IOError(EBADF, 'File descriptor was closed in another greenlet') 6 | FileObjectClosed = IOError(EBADF, 'Bad file descriptor (FileObject was closed)') 7 | 8 | PYPY = hasattr(sys, 'pypy_version_info') 9 | -------------------------------------------------------------------------------- /gevent/_util.pyx: -------------------------------------------------------------------------------- 1 | from python cimport * 2 | # Work around lack of absolute_import in Cython. 3 | os = __import__('os', level=0) 4 | 5 | # We implement __del__s in Cython so that they are safe against signals 6 | 7 | def SocketAdapter__del__(self, close=os.close): 8 | fileno = self._fileno 9 | if fileno is not None: 10 | self._fileno = None 11 | if self._close: 12 | close(fileno) 13 | 14 | 15 | def noop(self): 16 | pass 17 | -------------------------------------------------------------------------------- /gevent/_util_py2.py: -------------------------------------------------------------------------------- 1 | # this produces syntax error on Python3 2 | 3 | 4 | __all__ = ['reraise'] 5 | 6 | 7 | def reraise(type, value, tb): 8 | raise type, value, tb 9 | -------------------------------------------------------------------------------- /gevent/callbacks.h: -------------------------------------------------------------------------------- 1 | #define DEFINE_CALLBACK(WATCHER_LC, WATCHER_TYPE) \ 2 | static void gevent_callback_##WATCHER_LC(struct ev_loop *, void *, int); 3 | 4 | 5 | #define DEFINE_CALLBACKS0 \ 6 | DEFINE_CALLBACK(io, IO); \ 7 | DEFINE_CALLBACK(timer, Timer); \ 8 | DEFINE_CALLBACK(signal, Signal); \ 9 | DEFINE_CALLBACK(idle, Idle); \ 10 | DEFINE_CALLBACK(prepare, Prepare); \ 11 | DEFINE_CALLBACK(check, Check); \ 12 | DEFINE_CALLBACK(fork, Fork); \ 13 | DEFINE_CALLBACK(async, Async); \ 14 | DEFINE_CALLBACK(stat, Stat); 15 | 16 | 17 | #ifndef _WIN32 18 | 19 | #define DEFINE_CALLBACKS \ 20 | DEFINE_CALLBACKS0 \ 21 | DEFINE_CALLBACK(child, Child) 22 | 23 | #else 24 | 25 | #define DEFINE_CALLBACKS DEFINE_CALLBACKS0 26 | 27 | #endif 28 | 29 | 30 | DEFINE_CALLBACKS 31 | 32 | 33 | static void gevent_run_callbacks(struct ev_loop *, void *, int); 34 | struct PyGeventLoopObject; 35 | static void gevent_handle_error(struct PyGeventLoopObject* loop, PyObject* context); 36 | struct PyGeventCallbackObject; 37 | static void gevent_call(struct PyGeventLoopObject* loop, struct PyGeventCallbackObject* cb); 38 | 39 | #if defined(_WIN32) 40 | static void gevent_periodic_signal_check(struct ev_loop *, void *, int); 41 | #endif 42 | 43 | static void gevent_noop(struct ev_loop *_loop, void *watcher, int revents) { } 44 | -------------------------------------------------------------------------------- /gevent/cares_ntop.h: -------------------------------------------------------------------------------- 1 | #ifdef CARES_EMBED 2 | #include "ares_setup.h" 3 | #include "inet_ntop.h" 4 | #else 5 | #include 6 | #define ares_inet_ntop(w,x,y,z) inet_ntop(w,x,y,z) 7 | #endif 8 | -------------------------------------------------------------------------------- /gevent/cares_pton.h: -------------------------------------------------------------------------------- 1 | #ifdef CARES_EMBED 2 | #include "ares_setup.h" 3 | #include "inet_net_pton.h" 4 | #else 5 | #include 6 | #define ares_inet_pton(x,y,z) inet_pton(x,y,z) 7 | #define ares_inet_net_pton(w,x,y,z) inet_net_pton(w,x,y,z) 8 | #endif 9 | -------------------------------------------------------------------------------- /gevent/core.py: -------------------------------------------------------------------------------- 1 | from gevent.hub import PYPY 2 | 3 | if PYPY: 4 | from gevent import corecffi as _core 5 | else: 6 | from gevent import corecext as _core 7 | 8 | 9 | for item in dir(_core): 10 | if item.startswith('__'): 11 | continue 12 | globals()[item] = getattr(_core, item) 13 | 14 | 15 | __all__ = _core.__all__ 16 | -------------------------------------------------------------------------------- /gevent/coros.py: -------------------------------------------------------------------------------- 1 | # This module definitely remains in 1.0.x, probably in versions after that too. 2 | import warnings 3 | warnings.warn('gevent.coros has been renamed to gevent.lock', DeprecationWarning, stacklevel=2) 4 | 5 | from gevent.lock import * 6 | from gevent.lock import __all__ 7 | -------------------------------------------------------------------------------- /gevent/libev.h: -------------------------------------------------------------------------------- 1 | #if defined(LIBEV_EMBED) 2 | #include "ev.c" 3 | #else 4 | #include "ev.h" 5 | 6 | #ifndef _WIN32 7 | #include 8 | #endif 9 | 10 | #endif 11 | 12 | #ifndef _WIN32 13 | 14 | static struct sigaction libev_sigchld; 15 | static int sigchld_state = 0; 16 | 17 | static struct ev_loop* gevent_ev_default_loop(unsigned int flags) 18 | { 19 | if (sigchld_state) 20 | return ev_default_loop(flags); 21 | struct ev_loop* result; 22 | struct sigaction tmp; 23 | sigaction(SIGCHLD, NULL, &tmp); 24 | result = ev_default_loop(flags); 25 | // XXX what if SIGCHLD received there? 26 | sigaction(SIGCHLD, &tmp, &libev_sigchld); 27 | sigchld_state = 1; 28 | return result; 29 | } 30 | 31 | 32 | static void gevent_install_sigchld_handler(void) { 33 | if (sigchld_state == 1) { 34 | sigaction(SIGCHLD, &libev_sigchld, NULL); 35 | sigchld_state = 2; 36 | } 37 | } 38 | 39 | #else 40 | 41 | #define gevent_ev_default_loop ev_default_loop 42 | static void gevent_install_sigchld_handler(void) { } 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /gevent/python.pxd: -------------------------------------------------------------------------------- 1 | cdef extern from "Python.h": 2 | struct PyObject: 3 | pass 4 | ctypedef PyObject* PyObjectPtr "PyObject*" 5 | void Py_INCREF(PyObjectPtr) 6 | void Py_DECREF(PyObjectPtr) 7 | void Py_XDECREF(PyObjectPtr) 8 | int Py_ReprEnter(PyObjectPtr) 9 | void Py_ReprLeave(PyObjectPtr) 10 | int PyCallable_Check(PyObjectPtr) 11 | 12 | cdef extern from "frameobject.h": 13 | ctypedef struct PyThreadState: 14 | PyObjectPtr exc_type 15 | PyObjectPtr exc_value 16 | PyObjectPtr exc_traceback 17 | PyThreadState* PyThreadState_GET() 18 | -------------------------------------------------------------------------------- /gevent/resolver_thread.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2012 Denis Bilenko. See LICENSE for details. 2 | import _socket 3 | from gevent.hub import get_hub 4 | 5 | 6 | __all__ = ['Resolver'] 7 | 8 | 9 | class Resolver(object): 10 | 11 | expected_errors = Exception 12 | 13 | def __init__(self, hub=None): 14 | if hub is None: 15 | hub = get_hub() 16 | self.pool = hub.threadpool 17 | 18 | def __repr__(self): 19 | return '' % (id(self), self.pool) 20 | 21 | def close(self): 22 | pass 23 | 24 | # from briefly reading socketmodule.c, it seems that all of the functions 25 | # below are thread-safe in Python, even if they are not thread-safe in C. 26 | 27 | def gethostbyname(self, *args): 28 | return self.pool.apply_e(self.expected_errors, _socket.gethostbyname, args) 29 | 30 | def gethostbyname_ex(self, *args): 31 | return self.pool.apply_e(self.expected_errors, _socket.gethostbyname_ex, args) 32 | 33 | def getaddrinfo(self, *args, **kwargs): 34 | return self.pool.apply_e(self.expected_errors, _socket.getaddrinfo, args, kwargs) 35 | 36 | def gethostbyaddr(self, *args, **kwargs): 37 | return self.pool.apply_e(self.expected_errors, _socket.gethostbyaddr, args, kwargs) 38 | 39 | def getnameinfo(self, *args, **kwargs): 40 | return self.pool.apply_e(self.expected_errors, _socket.getnameinfo, args, kwargs) 41 | -------------------------------------------------------------------------------- /gevent/ssl.py: -------------------------------------------------------------------------------- 1 | from gevent.hub import PY3 2 | 3 | 4 | if PY3: 5 | from gevent import _ssl3 as _source 6 | else: 7 | from gevent import _ssl2 as _source 8 | 9 | 10 | for key in _source.__dict__: 11 | if key.startswith('__') and key not in '__implements__ __all__ __imports__'.split(): 12 | continue 13 | globals()[key] = getattr(_source, key) 14 | -------------------------------------------------------------------------------- /gevent/threading.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | 4 | __implements__ = ['local', 5 | '_start_new_thread', 6 | '_allocate_lock', 7 | 'Lock', 8 | '_sleep', 9 | '_DummyThread'] 10 | 11 | 12 | import threading as __threading__ 13 | _DummyThread_ = __threading__._DummyThread 14 | from gevent.local import local 15 | from gevent.thread import start_new_thread as _start_new_thread, allocate_lock as _allocate_lock 16 | from gevent.hub import sleep as _sleep, getcurrent, PY3 17 | if PY3: 18 | from gevent.thread import get_ident 19 | __implements__.append('get_ident') 20 | else: 21 | from gevent.thread import get_ident as _get_ident 22 | __implements__.append('_get_ident') 23 | Lock = _allocate_lock 24 | 25 | 26 | def _cleanup(g): 27 | __threading__._active.pop(id(g)) 28 | 29 | 30 | class _DummyThread(_DummyThread_): 31 | # instances of this will cleanup its own entry 32 | # in ``threading._active`` 33 | 34 | def __init__(self): 35 | _DummyThread_.__init__(self) 36 | g = getcurrent() 37 | rawlink = getattr(g, 'rawlink', None) 38 | if rawlink is not None: 39 | rawlink(_cleanup) 40 | 41 | def _Thread__stop(self): 42 | pass 43 | -------------------------------------------------------------------------------- /gevent/util.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2009 Denis Bilenko. See LICENSE for details. 2 | __all__ = ['wrap_errors'] 3 | 4 | import sys 5 | 6 | 7 | class wrap_errors(object): 8 | """Helper to make function return an exception, rather than raise it. 9 | 10 | Because every exception that is unhandled by greenlet will be logged, 11 | it is desirable to prevent non-error exceptions from leaving a greenlet. 12 | This can done with simple ``try``/``except`` construct:: 13 | 14 | def wrapped_func(*args, **kwargs): 15 | try: 16 | return func(*args, **kwargs) 17 | except (A, B, C) as ex: 18 | return ex 19 | 20 | :class:`wrap_errors` provides a shortcut to write that in one line:: 21 | 22 | wrapped_func = wrap_errors((A, B, C), func) 23 | 24 | It also preserves ``__str__`` and ``__repr__`` of the original function. 25 | """ 26 | # QQQ could also support using wrap_errors as a decorator 27 | 28 | def __init__(self, errors, func): 29 | """Make a new function from `func', such that it catches `errors' (an 30 | Exception subclass, or a tuple of Exception subclasses) and return 31 | it as a value. 32 | """ 33 | self.errors = errors 34 | self.func = func 35 | 36 | def __call__(self, *args, **kwargs): 37 | func = self.func 38 | try: 39 | return func(*args, **kwargs) 40 | except self.errors as ex: 41 | if sys.version_info[0] > 2: 42 | ex.__traceback__ = None 43 | return ex 44 | 45 | def __str__(self): 46 | return str(self.func) 47 | 48 | def __repr__(self): 49 | return repr(self.func) 50 | 51 | def __getattr__(self, item): 52 | return getattr(self.func, item) 53 | -------------------------------------------------------------------------------- /gevent/wsgi.py: -------------------------------------------------------------------------------- 1 | from gevent.pywsgi import * 2 | import gevent.pywsgi as _pywsgi 3 | __all__ = _pywsgi.__all__ 4 | del _pywsgi 5 | -------------------------------------------------------------------------------- /greentest/2.6/badcert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L 3 | opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH 4 | fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB 5 | AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU 6 | D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA 7 | IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM 8 | oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0 9 | ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/ 10 | loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j 11 | oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA 12 | z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq 13 | ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV 14 | q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU= 15 | -----END RSA PRIVATE KEY----- 16 | -----BEGIN CERTIFICATE----- 17 | Just bad cert data 18 | -----END CERTIFICATE----- 19 | -----BEGIN RSA PRIVATE KEY----- 20 | MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L 21 | opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH 22 | fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB 23 | AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU 24 | D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA 25 | IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM 26 | oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0 27 | ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/ 28 | loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j 29 | oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA 30 | z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq 31 | ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV 32 | q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU= 33 | -----END RSA PRIVATE KEY----- 34 | -----BEGIN CERTIFICATE----- 35 | Just bad cert data 36 | -----END CERTIFICATE----- 37 | -------------------------------------------------------------------------------- /greentest/2.6/keycert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L 3 | opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH 4 | fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB 5 | AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU 6 | D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA 7 | IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM 8 | oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0 9 | ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/ 10 | loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j 11 | oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA 12 | z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq 13 | ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV 14 | q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU= 15 | -----END RSA PRIVATE KEY----- 16 | -----BEGIN CERTIFICATE----- 17 | MIICpzCCAhCgAwIBAgIJAP+qStv1cIGNMA0GCSqGSIb3DQEBBQUAMIGJMQswCQYD 18 | VQQGEwJVUzERMA8GA1UECBMIRGVsYXdhcmUxEzARBgNVBAcTCldpbG1pbmd0b24x 19 | IzAhBgNVBAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMQwwCgYDVQQLEwNT 20 | U0wxHzAdBgNVBAMTFnNvbWVtYWNoaW5lLnB5dGhvbi5vcmcwHhcNMDcwODI3MTY1 21 | NDUwWhcNMTMwMjE2MTY1NDUwWjCBiTELMAkGA1UEBhMCVVMxETAPBgNVBAgTCERl 22 | bGF3YXJlMRMwEQYDVQQHEwpXaWxtaW5ndG9uMSMwIQYDVQQKExpQeXRob24gU29m 23 | dHdhcmUgRm91bmRhdGlvbjEMMAoGA1UECxMDU1NMMR8wHQYDVQQDExZzb21lbWFj 24 | aGluZS5weXRob24ub3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8ddrh 25 | m+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9LopdJhTvbGfEj0DQs1IE8 26 | M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVHfhi/VwovESJlaBOp+WMn 27 | fhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQABoxUwEzARBglghkgBhvhC 28 | AQEEBAMCBkAwDQYJKoZIhvcNAQEFBQADgYEAF4Q5BVqmCOLv1n8je/Jw9K669VXb 29 | 08hyGzQhkemEBYQd6fzQ9A/1ZzHkJKb1P6yreOLSEh4KcxYPyrLRC1ll8nr5OlCx 30 | CMhKkTnR6qBsdNV0XtdU2+N25hqW+Ma4ZeqsN/iiJVCGNOZGnvQuvCAGWF8+J/f/ 31 | iHkC6gGdBJhogs4= 32 | -----END CERTIFICATE----- 33 | -------------------------------------------------------------------------------- /greentest/2.6/nullcert.pem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantix/gevent/71dd2d4d1d3332ed87f79c19d54d97bdcacdcf6d/greentest/2.6/nullcert.pem -------------------------------------------------------------------------------- /greentest/2.6/version: -------------------------------------------------------------------------------- 1 | 2.6.8 2 | -------------------------------------------------------------------------------- /greentest/2.6/wrongcert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXAIBAAKBgQC89ZNxjTgWgq7Z1g0tJ65w+k7lNAj5IgjLb155UkUrz0XsHDnH 3 | FlbsVUg2Xtk6+bo2UEYIzN7cIm5ImpmyW/2z0J1IDVDlvR2xJ659xrE0v5c2cB6T 4 | f9lnNTwpSoeK24Nd7Jwq4j9vk95fLrdqsBq0/KVlsCXeixS/CaqqduXfvwIDAQAB 5 | AoGAQFko4uyCgzfxr4Ezb4Mp5pN3Npqny5+Jey3r8EjSAX9Ogn+CNYgoBcdtFgbq 6 | 1yif/0sK7ohGBJU9FUCAwrqNBI9ZHB6rcy7dx+gULOmRBGckln1o5S1+smVdmOsW 7 | 7zUVLBVByKuNWqTYFlzfVd6s4iiXtAE2iHn3GCyYdlICwrECQQDhMQVxHd3EFbzg 8 | SFmJBTARlZ2GKA3c1g/h9/XbkEPQ9/RwI3vnjJ2RaSnjlfoLl8TOcf0uOGbOEyFe 9 | 19RvCLXjAkEA1s+UE5ziF+YVkW3WolDCQ2kQ5WG9+ccfNebfh6b67B7Ln5iG0Sbg 10 | ky9cjsO3jbMJQtlzAQnH1850oRD5Gi51dQJAIbHCDLDZU9Ok1TI+I2BhVuA6F666 11 | lEZ7TeZaJSYq34OaUYUdrwG9OdqwZ9sy9LUav4ESzu2lhEQchCJrKMn23QJAReqs 12 | ZLHUeTjfXkVk7dHhWPWSlUZ6AhmIlA/AQ7Payg2/8wM/JkZEJEPvGVykms9iPUrv 13 | frADRr+hAGe43IewnQJBAJWKZllPgKuEBPwoEldHNS8nRu61D7HzxEzQ2xnfj+Nk 14 | 2fgf1MAzzTRsikfGENhVsVWeqOcijWb6g5gsyCmlRpc= 15 | -----END RSA PRIVATE KEY----- 16 | -----BEGIN CERTIFICATE----- 17 | MIICsDCCAhmgAwIBAgIJAOqYOYFJfEEoMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV 18 | BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX 19 | aWRnaXRzIFB0eSBMdGQwHhcNMDgwNjI2MTgxNTUyWhcNMDkwNjI2MTgxNTUyWjBF 20 | MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50 21 | ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB 22 | gQC89ZNxjTgWgq7Z1g0tJ65w+k7lNAj5IgjLb155UkUrz0XsHDnHFlbsVUg2Xtk6 23 | +bo2UEYIzN7cIm5ImpmyW/2z0J1IDVDlvR2xJ659xrE0v5c2cB6Tf9lnNTwpSoeK 24 | 24Nd7Jwq4j9vk95fLrdqsBq0/KVlsCXeixS/CaqqduXfvwIDAQABo4GnMIGkMB0G 25 | A1UdDgQWBBTctMtI3EO9OjLI0x9Zo2ifkwIiNjB1BgNVHSMEbjBsgBTctMtI3EO9 26 | OjLI0x9Zo2ifkwIiNqFJpEcwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUt 27 | U3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJAOqYOYFJ 28 | fEEoMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAQwa7jya/DfhaDn7E 29 | usPkpgIX8WCL2B1SqnRTXEZfBPPVq/cUmFGyEVRVATySRuMwi8PXbVcOhXXuocA+ 30 | 43W+iIsD9pXapCZhhOerCq18TC1dWK98vLUsoK8PMjB6e5H/O8bqojv0EeC+fyCw 31 | eSHj5jpC8iZKjCHBn+mAi4cQ514= 32 | -----END CERTIFICATE----- 33 | -------------------------------------------------------------------------------- /greentest/2.7/badcert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L 3 | opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH 4 | fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB 5 | AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU 6 | D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA 7 | IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM 8 | oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0 9 | ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/ 10 | loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j 11 | oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA 12 | z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq 13 | ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV 14 | q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU= 15 | -----END RSA PRIVATE KEY----- 16 | -----BEGIN CERTIFICATE----- 17 | Just bad cert data 18 | -----END CERTIFICATE----- 19 | -----BEGIN RSA PRIVATE KEY----- 20 | MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L 21 | opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH 22 | fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB 23 | AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU 24 | D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA 25 | IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM 26 | oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0 27 | ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/ 28 | loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j 29 | oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA 30 | z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq 31 | ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV 32 | q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU= 33 | -----END RSA PRIVATE KEY----- 34 | -----BEGIN CERTIFICATE----- 35 | Just bad cert data 36 | -----END CERTIFICATE----- 37 | -------------------------------------------------------------------------------- /greentest/2.7/keycert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L 3 | opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH 4 | fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB 5 | AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU 6 | D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA 7 | IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM 8 | oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0 9 | ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/ 10 | loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j 11 | oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA 12 | z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq 13 | ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV 14 | q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU= 15 | -----END RSA PRIVATE KEY----- 16 | -----BEGIN CERTIFICATE----- 17 | MIICpzCCAhCgAwIBAgIJAP+qStv1cIGNMA0GCSqGSIb3DQEBBQUAMIGJMQswCQYD 18 | VQQGEwJVUzERMA8GA1UECBMIRGVsYXdhcmUxEzARBgNVBAcTCldpbG1pbmd0b24x 19 | IzAhBgNVBAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMQwwCgYDVQQLEwNT 20 | U0wxHzAdBgNVBAMTFnNvbWVtYWNoaW5lLnB5dGhvbi5vcmcwHhcNMDcwODI3MTY1 21 | NDUwWhcNMTMwMjE2MTY1NDUwWjCBiTELMAkGA1UEBhMCVVMxETAPBgNVBAgTCERl 22 | bGF3YXJlMRMwEQYDVQQHEwpXaWxtaW5ndG9uMSMwIQYDVQQKExpQeXRob24gU29m 23 | dHdhcmUgRm91bmRhdGlvbjEMMAoGA1UECxMDU1NMMR8wHQYDVQQDExZzb21lbWFj 24 | aGluZS5weXRob24ub3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8ddrh 25 | m+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9LopdJhTvbGfEj0DQs1IE8 26 | M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVHfhi/VwovESJlaBOp+WMn 27 | fhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQABoxUwEzARBglghkgBhvhC 28 | AQEEBAMCBkAwDQYJKoZIhvcNAQEFBQADgYEAF4Q5BVqmCOLv1n8je/Jw9K669VXb 29 | 08hyGzQhkemEBYQd6fzQ9A/1ZzHkJKb1P6yreOLSEh4KcxYPyrLRC1ll8nr5OlCx 30 | CMhKkTnR6qBsdNV0XtdU2+N25hqW+Ma4ZeqsN/iiJVCGNOZGnvQuvCAGWF8+J/f/ 31 | iHkC6gGdBJhogs4= 32 | -----END CERTIFICATE----- 33 | -------------------------------------------------------------------------------- /greentest/2.7/nokia.pem: -------------------------------------------------------------------------------- 1 | # Certificate for projects.developer.nokia.com:443 (see issue 13034) 2 | -----BEGIN CERTIFICATE----- 3 | MIIFLDCCBBSgAwIBAgIQLubqdkCgdc7lAF9NfHlUmjANBgkqhkiG9w0BAQUFADCB 4 | vDELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL 5 | ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTswOQYDVQQLEzJUZXJtcyBvZiB1c2Ug 6 | YXQgaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL3JwYSAoYykxMDE2MDQGA1UEAxMt 7 | VmVyaVNpZ24gQ2xhc3MgMyBJbnRlcm5hdGlvbmFsIFNlcnZlciBDQSAtIEczMB4X 8 | DTExMDkyMTAwMDAwMFoXDTEyMDkyMDIzNTk1OVowcTELMAkGA1UEBhMCRkkxDjAM 9 | BgNVBAgTBUVzcG9vMQ4wDAYDVQQHFAVFc3BvbzEOMAwGA1UEChQFTm9raWExCzAJ 10 | BgNVBAsUAkJJMSUwIwYDVQQDFBxwcm9qZWN0cy5kZXZlbG9wZXIubm9raWEuY29t 11 | MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCr92w1bpHYSYxUEx8N/8Iddda2 12 | lYi+aXNtQfV/l2Fw9Ykv3Ipw4nLeGTj18FFlAZgMdPRlgrzF/NNXGw/9l3/qKdow 13 | CypkQf8lLaxb9Ze1E/KKmkRJa48QTOqvo6GqKuTI6HCeGlG1RxDb8YSKcQWLiytn 14 | yj3Wp4MgRQO266xmMQIDAQABo4IB9jCCAfIwQQYDVR0RBDowOIIccHJvamVjdHMu 15 | ZGV2ZWxvcGVyLm5va2lhLmNvbYIYcHJvamVjdHMuZm9ydW0ubm9raWEuY29tMAkG 16 | A1UdEwQCMAAwCwYDVR0PBAQDAgWgMEEGA1UdHwQ6MDgwNqA0oDKGMGh0dHA6Ly9T 17 | VlJJbnRsLUczLWNybC52ZXJpc2lnbi5jb20vU1ZSSW50bEczLmNybDBEBgNVHSAE 18 | PTA7MDkGC2CGSAGG+EUBBxcDMCowKAYIKwYBBQUHAgEWHGh0dHBzOi8vd3d3LnZl 19 | cmlzaWduLmNvbS9ycGEwKAYDVR0lBCEwHwYJYIZIAYb4QgQBBggrBgEFBQcDAQYI 20 | KwYBBQUHAwIwcgYIKwYBBQUHAQEEZjBkMCQGCCsGAQUFBzABhhhodHRwOi8vb2Nz 21 | cC52ZXJpc2lnbi5jb20wPAYIKwYBBQUHMAKGMGh0dHA6Ly9TVlJJbnRsLUczLWFp 22 | YS52ZXJpc2lnbi5jb20vU1ZSSW50bEczLmNlcjBuBggrBgEFBQcBDARiMGChXqBc 23 | MFowWDBWFglpbWFnZS9naWYwITAfMAcGBSsOAwIaBBRLa7kolgYMu9BSOJsprEsH 24 | iyEFGDAmFiRodHRwOi8vbG9nby52ZXJpc2lnbi5jb20vdnNsb2dvMS5naWYwDQYJ 25 | KoZIhvcNAQEFBQADggEBACQuPyIJqXwUyFRWw9x5yDXgMW4zYFopQYOw/ItRY522 26 | O5BsySTh56BWS6mQB07XVfxmYUGAvRQDA5QHpmY8jIlNwSmN3s8RKo+fAtiNRlcL 27 | x/mWSfuMs3D/S6ev3D6+dpEMZtjrhOdctsarMKp8n/hPbwhAbg5hVjpkW5n8vz2y 28 | 0KxvvkA1AxpLwpVv7OlK17ttzIHw8bp9HTlHBU5s8bKz4a565V/a5HI0CSEv/+0y 29 | ko4/ghTnZc1CkmUngKKeFMSah/mT/xAh8XnE2l1AazFa8UKuYki1e+ArHaGZc4ix 30 | UYOtiRphwfuYQhRZ7qX9q2MMkCMI65XNK/SaFrAbbG0= 31 | -----END CERTIFICATE----- 32 | -------------------------------------------------------------------------------- /greentest/2.7/nullcert.pem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantix/gevent/71dd2d4d1d3332ed87f79c19d54d97bdcacdcf6d/greentest/2.7/nullcert.pem -------------------------------------------------------------------------------- /greentest/2.7/subprocessdata/sigchild_ignore.py: -------------------------------------------------------------------------------- 1 | import signal, subprocess, sys 2 | # On Linux this causes os.waitpid to fail with OSError as the OS has already 3 | # reaped our child process. The wait() passing the OSError on to the caller 4 | # and causing us to exit with an error is what we are testing against. 5 | signal.signal(signal.SIGCHLD, signal.SIG_IGN) 6 | subprocess.Popen([sys.executable, '-c', 'print("albatross")']).wait() 7 | -------------------------------------------------------------------------------- /greentest/2.7/test_select.py: -------------------------------------------------------------------------------- 1 | from test import test_support 2 | import unittest 3 | import select 4 | import os 5 | import sys 6 | 7 | @unittest.skipIf(sys.platform[:3] in ('win', 'os2', 'riscos'), 8 | "can't easily test on this system") 9 | class SelectTestCase(unittest.TestCase): 10 | 11 | class Nope: 12 | pass 13 | 14 | class Almost: 15 | def fileno(self): 16 | return 'fileno' 17 | 18 | def test_error_conditions(self): 19 | self.assertRaises(TypeError, select.select, 1, 2, 3) 20 | self.assertRaises(TypeError, select.select, [self.Nope()], [], []) 21 | self.assertRaises(TypeError, select.select, [self.Almost()], [], []) 22 | self.assertRaises(TypeError, select.select, [], [], [], "not a number") 23 | 24 | def test_returned_list_identity(self): 25 | # See issue #8329 26 | r, w, x = select.select([], [], [], 1) 27 | self.assertIsNot(r, w) 28 | self.assertIsNot(r, x) 29 | self.assertIsNot(w, x) 30 | 31 | def test_select(self): 32 | cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 0.1; done' 33 | p = os.popen(cmd, 'r') 34 | for tout in (0, 0.1, 0.2, 0.4, 0.8, 1.6) + (None,)*10: 35 | if test_support.verbose: 36 | print 'timeout =', tout 37 | rfd, wfd, xfd = select.select([p], [], [], tout) 38 | if (rfd, wfd, xfd) == ([], [], []): 39 | continue 40 | if (rfd, wfd, xfd) == ([p], [], []): 41 | line = p.readline() 42 | if test_support.verbose: 43 | print repr(line) 44 | if not line: 45 | if test_support.verbose: 46 | print 'EOF' 47 | break 48 | continue 49 | self.fail('Unexpected return values from select():', rfd, wfd, xfd) 50 | p.close() 51 | 52 | 53 | def test_main(): 54 | test_support.run_unittest(SelectTestCase) 55 | test_support.reap_children() 56 | 57 | if __name__ == "__main__": 58 | test_main() 59 | -------------------------------------------------------------------------------- /greentest/2.7/version: -------------------------------------------------------------------------------- 1 | 2.7.3 2 | -------------------------------------------------------------------------------- /greentest/2.7/wrongcert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXAIBAAKBgQC89ZNxjTgWgq7Z1g0tJ65w+k7lNAj5IgjLb155UkUrz0XsHDnH 3 | FlbsVUg2Xtk6+bo2UEYIzN7cIm5ImpmyW/2z0J1IDVDlvR2xJ659xrE0v5c2cB6T 4 | f9lnNTwpSoeK24Nd7Jwq4j9vk95fLrdqsBq0/KVlsCXeixS/CaqqduXfvwIDAQAB 5 | AoGAQFko4uyCgzfxr4Ezb4Mp5pN3Npqny5+Jey3r8EjSAX9Ogn+CNYgoBcdtFgbq 6 | 1yif/0sK7ohGBJU9FUCAwrqNBI9ZHB6rcy7dx+gULOmRBGckln1o5S1+smVdmOsW 7 | 7zUVLBVByKuNWqTYFlzfVd6s4iiXtAE2iHn3GCyYdlICwrECQQDhMQVxHd3EFbzg 8 | SFmJBTARlZ2GKA3c1g/h9/XbkEPQ9/RwI3vnjJ2RaSnjlfoLl8TOcf0uOGbOEyFe 9 | 19RvCLXjAkEA1s+UE5ziF+YVkW3WolDCQ2kQ5WG9+ccfNebfh6b67B7Ln5iG0Sbg 10 | ky9cjsO3jbMJQtlzAQnH1850oRD5Gi51dQJAIbHCDLDZU9Ok1TI+I2BhVuA6F666 11 | lEZ7TeZaJSYq34OaUYUdrwG9OdqwZ9sy9LUav4ESzu2lhEQchCJrKMn23QJAReqs 12 | ZLHUeTjfXkVk7dHhWPWSlUZ6AhmIlA/AQ7Payg2/8wM/JkZEJEPvGVykms9iPUrv 13 | frADRr+hAGe43IewnQJBAJWKZllPgKuEBPwoEldHNS8nRu61D7HzxEzQ2xnfj+Nk 14 | 2fgf1MAzzTRsikfGENhVsVWeqOcijWb6g5gsyCmlRpc= 15 | -----END RSA PRIVATE KEY----- 16 | -----BEGIN CERTIFICATE----- 17 | MIICsDCCAhmgAwIBAgIJAOqYOYFJfEEoMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV 18 | BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX 19 | aWRnaXRzIFB0eSBMdGQwHhcNMDgwNjI2MTgxNTUyWhcNMDkwNjI2MTgxNTUyWjBF 20 | MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50 21 | ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB 22 | gQC89ZNxjTgWgq7Z1g0tJ65w+k7lNAj5IgjLb155UkUrz0XsHDnHFlbsVUg2Xtk6 23 | +bo2UEYIzN7cIm5ImpmyW/2z0J1IDVDlvR2xJ659xrE0v5c2cB6Tf9lnNTwpSoeK 24 | 24Nd7Jwq4j9vk95fLrdqsBq0/KVlsCXeixS/CaqqduXfvwIDAQABo4GnMIGkMB0G 25 | A1UdDgQWBBTctMtI3EO9OjLI0x9Zo2ifkwIiNjB1BgNVHSMEbjBsgBTctMtI3EO9 26 | OjLI0x9Zo2ifkwIiNqFJpEcwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUt 27 | U3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJAOqYOYFJ 28 | fEEoMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAQwa7jya/DfhaDn7E 29 | usPkpgIX8WCL2B1SqnRTXEZfBPPVq/cUmFGyEVRVATySRuMwi8PXbVcOhXXuocA+ 30 | 43W+iIsD9pXapCZhhOerCq18TC1dWK98vLUsoK8PMjB6e5H/O8bqojv0EeC+fyCw 31 | eSHj5jpC8iZKjCHBn+mAi4cQ514= 32 | -----END CERTIFICATE----- 33 | -------------------------------------------------------------------------------- /greentest/2.7pypy/badcert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L 3 | opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH 4 | fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB 5 | AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU 6 | D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA 7 | IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM 8 | oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0 9 | ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/ 10 | loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j 11 | oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA 12 | z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq 13 | ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV 14 | q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU= 15 | -----END RSA PRIVATE KEY----- 16 | -----BEGIN CERTIFICATE----- 17 | Just bad cert data 18 | -----END CERTIFICATE----- 19 | -----BEGIN RSA PRIVATE KEY----- 20 | MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L 21 | opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH 22 | fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB 23 | AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU 24 | D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA 25 | IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM 26 | oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0 27 | ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/ 28 | loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j 29 | oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA 30 | z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq 31 | ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV 32 | q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU= 33 | -----END RSA PRIVATE KEY----- 34 | -----BEGIN CERTIFICATE----- 35 | Just bad cert data 36 | -----END CERTIFICATE----- 37 | -------------------------------------------------------------------------------- /greentest/2.7pypy/keycert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANtb0+YrKuxevGpm 3 | LrjaUhZSgz6zFAmuGFmKmUbdjmfv9zSmmdsQIksK++jK0Be9LeZy20j6ahOfuVa0 4 | ufEmPoP7Fy4hXegKZR9cCWcIe/A6H2xWF1IIJLRTLaU8ol/I7T+um5HD5AwAwNPP 5 | USNU0Eegmvp+xxWu3NX2m1Veot85AgMBAAECgYA3ZdZ673X0oexFlq7AAmrutkHt 6 | CL7LvwrpOiaBjhyTxTeSNWzvtQBkIU8DOI0bIazA4UreAFffwtvEuPmonDb3F+Iq 7 | SMAu42XcGyVZEl+gHlTPU9XRX7nTOXVt+MlRRRxL6t9GkGfUAXI3XxJDXW3c0vBK 8 | UL9xqD8cORXOfE06rQJBAP8mEX1ERkR64Ptsoe4281vjTlNfIbs7NMPkUnrn9N/Y 9 | BLhjNIfQ3HFZG8BTMLfX7kCS9D593DW5tV4Z9BP/c6cCQQDcFzCcVArNh2JSywOQ 10 | ZfTfRbJg/Z5Lt9Fkngv1meeGNPgIMLN8Sg679pAOOWmzdMO3V706rNPzSVMME7E5 11 | oPIfAkEA8pDddarP5tCvTTgUpmTFbakm0KoTZm2+FzHcnA4jRh+XNTjTOv98Y6Ik 12 | eO5d1ZnKXseWvkZncQgxfdnMqqpj5wJAcNq/RVne1DbYlwWchT2Si65MYmmJ8t+F 13 | 0mcsULqjOnEMwf5e+ptq5LzwbyrHZYq5FNk7ocufPv/ZQrcSSC+cFwJBAKvOJByS 14 | x56qyGeZLOQlWS2JS3KJo59XuLFGqcbgN9Om9xFa41Yb4N9NvplFivsvZdw3m1Q/ 15 | SPIXQuT8RMPDVNQ= 16 | -----END PRIVATE KEY----- 17 | -----BEGIN CERTIFICATE----- 18 | MIICVDCCAb2gAwIBAgIJANfHOBkZr8JOMA0GCSqGSIb3DQEBBQUAMF8xCzAJBgNV 19 | BAYTAlhZMRcwFQYDVQQHEw5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9u 20 | IFNvZnR3YXJlIEZvdW5kYXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDAeFw0xMDEw 21 | MDgyMzAxNTZaFw0yMDEwMDUyMzAxNTZaMF8xCzAJBgNVBAYTAlhZMRcwFQYDVQQH 22 | Ew5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9uIFNvZnR3YXJlIEZvdW5k 23 | YXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAw 24 | gYkCgYEA21vT5isq7F68amYuuNpSFlKDPrMUCa4YWYqZRt2OZ+/3NKaZ2xAiSwr7 25 | 6MrQF70t5nLbSPpqE5+5VrS58SY+g/sXLiFd6AplH1wJZwh78DofbFYXUggktFMt 26 | pTyiX8jtP66bkcPkDADA089RI1TQR6Ca+n7HFa7c1fabVV6i3zkCAwEAAaMYMBYw 27 | FAYDVR0RBA0wC4IJbG9jYWxob3N0MA0GCSqGSIb3DQEBBQUAA4GBAHPctQBEQ4wd 28 | BJ6+JcpIraopLn8BGhbjNWj40mmRqWB/NAWF6M5ne7KpGAu7tLeG4hb1zLaldK8G 29 | lxy2GPSRF6LFS48dpEj2HbMv2nvv6xxalDMJ9+DicWgAKTQ6bcX2j3GUkCR0g/T1 30 | CRlNBAAlvhKzO7Clpf9l0YKBEfraJByX 31 | -----END CERTIFICATE----- 32 | -------------------------------------------------------------------------------- /greentest/2.7pypy/nokia.pem: -------------------------------------------------------------------------------- 1 | # Certificate for projects.developer.nokia.com:443 (see issue 13034) 2 | -----BEGIN CERTIFICATE----- 3 | MIIFLDCCBBSgAwIBAgIQLubqdkCgdc7lAF9NfHlUmjANBgkqhkiG9w0BAQUFADCB 4 | vDELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL 5 | ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTswOQYDVQQLEzJUZXJtcyBvZiB1c2Ug 6 | YXQgaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL3JwYSAoYykxMDE2MDQGA1UEAxMt 7 | VmVyaVNpZ24gQ2xhc3MgMyBJbnRlcm5hdGlvbmFsIFNlcnZlciBDQSAtIEczMB4X 8 | DTExMDkyMTAwMDAwMFoXDTEyMDkyMDIzNTk1OVowcTELMAkGA1UEBhMCRkkxDjAM 9 | BgNVBAgTBUVzcG9vMQ4wDAYDVQQHFAVFc3BvbzEOMAwGA1UEChQFTm9raWExCzAJ 10 | BgNVBAsUAkJJMSUwIwYDVQQDFBxwcm9qZWN0cy5kZXZlbG9wZXIubm9raWEuY29t 11 | MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCr92w1bpHYSYxUEx8N/8Iddda2 12 | lYi+aXNtQfV/l2Fw9Ykv3Ipw4nLeGTj18FFlAZgMdPRlgrzF/NNXGw/9l3/qKdow 13 | CypkQf8lLaxb9Ze1E/KKmkRJa48QTOqvo6GqKuTI6HCeGlG1RxDb8YSKcQWLiytn 14 | yj3Wp4MgRQO266xmMQIDAQABo4IB9jCCAfIwQQYDVR0RBDowOIIccHJvamVjdHMu 15 | ZGV2ZWxvcGVyLm5va2lhLmNvbYIYcHJvamVjdHMuZm9ydW0ubm9raWEuY29tMAkG 16 | A1UdEwQCMAAwCwYDVR0PBAQDAgWgMEEGA1UdHwQ6MDgwNqA0oDKGMGh0dHA6Ly9T 17 | VlJJbnRsLUczLWNybC52ZXJpc2lnbi5jb20vU1ZSSW50bEczLmNybDBEBgNVHSAE 18 | PTA7MDkGC2CGSAGG+EUBBxcDMCowKAYIKwYBBQUHAgEWHGh0dHBzOi8vd3d3LnZl 19 | cmlzaWduLmNvbS9ycGEwKAYDVR0lBCEwHwYJYIZIAYb4QgQBBggrBgEFBQcDAQYI 20 | KwYBBQUHAwIwcgYIKwYBBQUHAQEEZjBkMCQGCCsGAQUFBzABhhhodHRwOi8vb2Nz 21 | cC52ZXJpc2lnbi5jb20wPAYIKwYBBQUHMAKGMGh0dHA6Ly9TVlJJbnRsLUczLWFp 22 | YS52ZXJpc2lnbi5jb20vU1ZSSW50bEczLmNlcjBuBggrBgEFBQcBDARiMGChXqBc 23 | MFowWDBWFglpbWFnZS9naWYwITAfMAcGBSsOAwIaBBRLa7kolgYMu9BSOJsprEsH 24 | iyEFGDAmFiRodHRwOi8vbG9nby52ZXJpc2lnbi5jb20vdnNsb2dvMS5naWYwDQYJ 25 | KoZIhvcNAQEFBQADggEBACQuPyIJqXwUyFRWw9x5yDXgMW4zYFopQYOw/ItRY522 26 | O5BsySTh56BWS6mQB07XVfxmYUGAvRQDA5QHpmY8jIlNwSmN3s8RKo+fAtiNRlcL 27 | x/mWSfuMs3D/S6ev3D6+dpEMZtjrhOdctsarMKp8n/hPbwhAbg5hVjpkW5n8vz2y 28 | 0KxvvkA1AxpLwpVv7OlK17ttzIHw8bp9HTlHBU5s8bKz4a565V/a5HI0CSEv/+0y 29 | ko4/ghTnZc1CkmUngKKeFMSah/mT/xAh8XnE2l1AazFa8UKuYki1e+ArHaGZc4ix 30 | UYOtiRphwfuYQhRZ7qX9q2MMkCMI65XNK/SaFrAbbG0= 31 | -----END CERTIFICATE----- 32 | -------------------------------------------------------------------------------- /greentest/2.7pypy/nullcert.pem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantix/gevent/71dd2d4d1d3332ed87f79c19d54d97bdcacdcf6d/greentest/2.7pypy/nullcert.pem -------------------------------------------------------------------------------- /greentest/2.7pypy/subprocessdata/sigchild_ignore.py: -------------------------------------------------------------------------------- 1 | import signal, subprocess, sys 2 | # On Linux this causes os.waitpid to fail with OSError as the OS has already 3 | # reaped our child process. The wait() passing the OSError on to the caller 4 | # and causing us to exit with an error is what we are testing against. 5 | signal.signal(signal.SIGCHLD, signal.SIG_IGN) 6 | subprocess.Popen([sys.executable, '-c', 'print("albatross")']).wait() 7 | -------------------------------------------------------------------------------- /greentest/2.7pypy/test_select.py: -------------------------------------------------------------------------------- 1 | from test import test_support 2 | import unittest 3 | import select 4 | import os 5 | import sys 6 | 7 | @unittest.skipIf(sys.platform[:3] in ('win', 'os2', 'riscos'), 8 | "can't easily test on this system") 9 | class SelectTestCase(unittest.TestCase): 10 | 11 | class Nope: 12 | pass 13 | 14 | class Almost: 15 | def fileno(self): 16 | return 'fileno' 17 | 18 | def test_error_conditions(self): 19 | self.assertRaises(TypeError, select.select, 1, 2, 3) 20 | self.assertRaises(TypeError, select.select, [self.Nope()], [], []) 21 | self.assertRaises(TypeError, select.select, [self.Almost()], [], []) 22 | self.assertRaises(TypeError, select.select, [], [], [], "not a number") 23 | 24 | def test_returned_list_identity(self): 25 | # See issue #8329 26 | r, w, x = select.select([], [], [], 1) 27 | self.assertIsNot(r, w) 28 | self.assertIsNot(r, x) 29 | self.assertIsNot(w, x) 30 | 31 | def test_select(self): 32 | cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 0.1; done' 33 | p = os.popen(cmd, 'r') 34 | for tout in (0, 0.1, 0.2, 0.4, 0.8, 1.6) + (None,)*10: 35 | if test_support.verbose: 36 | print 'timeout =', tout 37 | rfd, wfd, xfd = select.select([p], [], [], tout) 38 | if (rfd, wfd, xfd) == ([], [], []): 39 | continue 40 | if (rfd, wfd, xfd) == ([p], [], []): 41 | line = p.readline() 42 | if test_support.verbose: 43 | print repr(line) 44 | if not line: 45 | if test_support.verbose: 46 | print 'EOF' 47 | break 48 | continue 49 | self.fail('Unexpected return values from select():', rfd, wfd, xfd) 50 | p.close() 51 | 52 | 53 | def test_main(): 54 | test_support.run_unittest(SelectTestCase) 55 | test_support.reap_children() 56 | 57 | if __name__ == "__main__": 58 | test_main() 59 | -------------------------------------------------------------------------------- /greentest/2.7pypy/version: -------------------------------------------------------------------------------- 1 | 2.7.3 2 | -------------------------------------------------------------------------------- /greentest/2.7pypy/wrongcert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXAIBAAKBgQC89ZNxjTgWgq7Z1g0tJ65w+k7lNAj5IgjLb155UkUrz0XsHDnH 3 | FlbsVUg2Xtk6+bo2UEYIzN7cIm5ImpmyW/2z0J1IDVDlvR2xJ659xrE0v5c2cB6T 4 | f9lnNTwpSoeK24Nd7Jwq4j9vk95fLrdqsBq0/KVlsCXeixS/CaqqduXfvwIDAQAB 5 | AoGAQFko4uyCgzfxr4Ezb4Mp5pN3Npqny5+Jey3r8EjSAX9Ogn+CNYgoBcdtFgbq 6 | 1yif/0sK7ohGBJU9FUCAwrqNBI9ZHB6rcy7dx+gULOmRBGckln1o5S1+smVdmOsW 7 | 7zUVLBVByKuNWqTYFlzfVd6s4iiXtAE2iHn3GCyYdlICwrECQQDhMQVxHd3EFbzg 8 | SFmJBTARlZ2GKA3c1g/h9/XbkEPQ9/RwI3vnjJ2RaSnjlfoLl8TOcf0uOGbOEyFe 9 | 19RvCLXjAkEA1s+UE5ziF+YVkW3WolDCQ2kQ5WG9+ccfNebfh6b67B7Ln5iG0Sbg 10 | ky9cjsO3jbMJQtlzAQnH1850oRD5Gi51dQJAIbHCDLDZU9Ok1TI+I2BhVuA6F666 11 | lEZ7TeZaJSYq34OaUYUdrwG9OdqwZ9sy9LUav4ESzu2lhEQchCJrKMn23QJAReqs 12 | ZLHUeTjfXkVk7dHhWPWSlUZ6AhmIlA/AQ7Payg2/8wM/JkZEJEPvGVykms9iPUrv 13 | frADRr+hAGe43IewnQJBAJWKZllPgKuEBPwoEldHNS8nRu61D7HzxEzQ2xnfj+Nk 14 | 2fgf1MAzzTRsikfGENhVsVWeqOcijWb6g5gsyCmlRpc= 15 | -----END RSA PRIVATE KEY----- 16 | -----BEGIN CERTIFICATE----- 17 | MIICsDCCAhmgAwIBAgIJAOqYOYFJfEEoMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV 18 | BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX 19 | aWRnaXRzIFB0eSBMdGQwHhcNMDgwNjI2MTgxNTUyWhcNMDkwNjI2MTgxNTUyWjBF 20 | MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50 21 | ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB 22 | gQC89ZNxjTgWgq7Z1g0tJ65w+k7lNAj5IgjLb155UkUrz0XsHDnHFlbsVUg2Xtk6 23 | +bo2UEYIzN7cIm5ImpmyW/2z0J1IDVDlvR2xJ659xrE0v5c2cB6Tf9lnNTwpSoeK 24 | 24Nd7Jwq4j9vk95fLrdqsBq0/KVlsCXeixS/CaqqduXfvwIDAQABo4GnMIGkMB0G 25 | A1UdDgQWBBTctMtI3EO9OjLI0x9Zo2ifkwIiNjB1BgNVHSMEbjBsgBTctMtI3EO9 26 | OjLI0x9Zo2ifkwIiNqFJpEcwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUt 27 | U3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJAOqYOYFJ 28 | fEEoMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAQwa7jya/DfhaDn7E 29 | usPkpgIX8WCL2B1SqnRTXEZfBPPVq/cUmFGyEVRVATySRuMwi8PXbVcOhXXuocA+ 30 | 43W+iIsD9pXapCZhhOerCq18TC1dWK98vLUsoK8PMjB6e5H/O8bqojv0EeC+fyCw 31 | eSHj5jpC8iZKjCHBn+mAi4cQ514= 32 | -----END CERTIFICATE----- 33 | -------------------------------------------------------------------------------- /greentest/3.3/badcert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L 3 | opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH 4 | fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB 5 | AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU 6 | D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA 7 | IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM 8 | oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0 9 | ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/ 10 | loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j 11 | oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA 12 | z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq 13 | ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV 14 | q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU= 15 | -----END RSA PRIVATE KEY----- 16 | -----BEGIN CERTIFICATE----- 17 | Just bad cert data 18 | -----END CERTIFICATE----- 19 | -----BEGIN RSA PRIVATE KEY----- 20 | MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L 21 | opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH 22 | fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB 23 | AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU 24 | D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA 25 | IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM 26 | oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0 27 | ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/ 28 | loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j 29 | oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA 30 | z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq 31 | ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV 32 | q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU= 33 | -----END RSA PRIVATE KEY----- 34 | -----BEGIN CERTIFICATE----- 35 | Just bad cert data 36 | -----END CERTIFICATE----- 37 | -------------------------------------------------------------------------------- /greentest/3.3/keycert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANtb0+YrKuxevGpm 3 | LrjaUhZSgz6zFAmuGFmKmUbdjmfv9zSmmdsQIksK++jK0Be9LeZy20j6ahOfuVa0 4 | ufEmPoP7Fy4hXegKZR9cCWcIe/A6H2xWF1IIJLRTLaU8ol/I7T+um5HD5AwAwNPP 5 | USNU0Eegmvp+xxWu3NX2m1Veot85AgMBAAECgYA3ZdZ673X0oexFlq7AAmrutkHt 6 | CL7LvwrpOiaBjhyTxTeSNWzvtQBkIU8DOI0bIazA4UreAFffwtvEuPmonDb3F+Iq 7 | SMAu42XcGyVZEl+gHlTPU9XRX7nTOXVt+MlRRRxL6t9GkGfUAXI3XxJDXW3c0vBK 8 | UL9xqD8cORXOfE06rQJBAP8mEX1ERkR64Ptsoe4281vjTlNfIbs7NMPkUnrn9N/Y 9 | BLhjNIfQ3HFZG8BTMLfX7kCS9D593DW5tV4Z9BP/c6cCQQDcFzCcVArNh2JSywOQ 10 | ZfTfRbJg/Z5Lt9Fkngv1meeGNPgIMLN8Sg679pAOOWmzdMO3V706rNPzSVMME7E5 11 | oPIfAkEA8pDddarP5tCvTTgUpmTFbakm0KoTZm2+FzHcnA4jRh+XNTjTOv98Y6Ik 12 | eO5d1ZnKXseWvkZncQgxfdnMqqpj5wJAcNq/RVne1DbYlwWchT2Si65MYmmJ8t+F 13 | 0mcsULqjOnEMwf5e+ptq5LzwbyrHZYq5FNk7ocufPv/ZQrcSSC+cFwJBAKvOJByS 14 | x56qyGeZLOQlWS2JS3KJo59XuLFGqcbgN9Om9xFa41Yb4N9NvplFivsvZdw3m1Q/ 15 | SPIXQuT8RMPDVNQ= 16 | -----END PRIVATE KEY----- 17 | -----BEGIN CERTIFICATE----- 18 | MIICVDCCAb2gAwIBAgIJANfHOBkZr8JOMA0GCSqGSIb3DQEBBQUAMF8xCzAJBgNV 19 | BAYTAlhZMRcwFQYDVQQHEw5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9u 20 | IFNvZnR3YXJlIEZvdW5kYXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDAeFw0xMDEw 21 | MDgyMzAxNTZaFw0yMDEwMDUyMzAxNTZaMF8xCzAJBgNVBAYTAlhZMRcwFQYDVQQH 22 | Ew5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9uIFNvZnR3YXJlIEZvdW5k 23 | YXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAw 24 | gYkCgYEA21vT5isq7F68amYuuNpSFlKDPrMUCa4YWYqZRt2OZ+/3NKaZ2xAiSwr7 25 | 6MrQF70t5nLbSPpqE5+5VrS58SY+g/sXLiFd6AplH1wJZwh78DofbFYXUggktFMt 26 | pTyiX8jtP66bkcPkDADA089RI1TQR6Ca+n7HFa7c1fabVV6i3zkCAwEAAaMYMBYw 27 | FAYDVR0RBA0wC4IJbG9jYWxob3N0MA0GCSqGSIb3DQEBBQUAA4GBAHPctQBEQ4wd 28 | BJ6+JcpIraopLn8BGhbjNWj40mmRqWB/NAWF6M5ne7KpGAu7tLeG4hb1zLaldK8G 29 | lxy2GPSRF6LFS48dpEj2HbMv2nvv6xxalDMJ9+DicWgAKTQ6bcX2j3GUkCR0g/T1 30 | CRlNBAAlvhKzO7Clpf9l0YKBEfraJByX 31 | -----END CERTIFICATE----- 32 | -------------------------------------------------------------------------------- /greentest/3.3/nokia.pem: -------------------------------------------------------------------------------- 1 | # Certificate for projects.developer.nokia.com:443 (see issue 13034) 2 | -----BEGIN CERTIFICATE----- 3 | MIIFLDCCBBSgAwIBAgIQLubqdkCgdc7lAF9NfHlUmjANBgkqhkiG9w0BAQUFADCB 4 | vDELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL 5 | ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTswOQYDVQQLEzJUZXJtcyBvZiB1c2Ug 6 | YXQgaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL3JwYSAoYykxMDE2MDQGA1UEAxMt 7 | VmVyaVNpZ24gQ2xhc3MgMyBJbnRlcm5hdGlvbmFsIFNlcnZlciBDQSAtIEczMB4X 8 | DTExMDkyMTAwMDAwMFoXDTEyMDkyMDIzNTk1OVowcTELMAkGA1UEBhMCRkkxDjAM 9 | BgNVBAgTBUVzcG9vMQ4wDAYDVQQHFAVFc3BvbzEOMAwGA1UEChQFTm9raWExCzAJ 10 | BgNVBAsUAkJJMSUwIwYDVQQDFBxwcm9qZWN0cy5kZXZlbG9wZXIubm9raWEuY29t 11 | MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCr92w1bpHYSYxUEx8N/8Iddda2 12 | lYi+aXNtQfV/l2Fw9Ykv3Ipw4nLeGTj18FFlAZgMdPRlgrzF/NNXGw/9l3/qKdow 13 | CypkQf8lLaxb9Ze1E/KKmkRJa48QTOqvo6GqKuTI6HCeGlG1RxDb8YSKcQWLiytn 14 | yj3Wp4MgRQO266xmMQIDAQABo4IB9jCCAfIwQQYDVR0RBDowOIIccHJvamVjdHMu 15 | ZGV2ZWxvcGVyLm5va2lhLmNvbYIYcHJvamVjdHMuZm9ydW0ubm9raWEuY29tMAkG 16 | A1UdEwQCMAAwCwYDVR0PBAQDAgWgMEEGA1UdHwQ6MDgwNqA0oDKGMGh0dHA6Ly9T 17 | VlJJbnRsLUczLWNybC52ZXJpc2lnbi5jb20vU1ZSSW50bEczLmNybDBEBgNVHSAE 18 | PTA7MDkGC2CGSAGG+EUBBxcDMCowKAYIKwYBBQUHAgEWHGh0dHBzOi8vd3d3LnZl 19 | cmlzaWduLmNvbS9ycGEwKAYDVR0lBCEwHwYJYIZIAYb4QgQBBggrBgEFBQcDAQYI 20 | KwYBBQUHAwIwcgYIKwYBBQUHAQEEZjBkMCQGCCsGAQUFBzABhhhodHRwOi8vb2Nz 21 | cC52ZXJpc2lnbi5jb20wPAYIKwYBBQUHMAKGMGh0dHA6Ly9TVlJJbnRsLUczLWFp 22 | YS52ZXJpc2lnbi5jb20vU1ZSSW50bEczLmNlcjBuBggrBgEFBQcBDARiMGChXqBc 23 | MFowWDBWFglpbWFnZS9naWYwITAfMAcGBSsOAwIaBBRLa7kolgYMu9BSOJsprEsH 24 | iyEFGDAmFiRodHRwOi8vbG9nby52ZXJpc2lnbi5jb20vdnNsb2dvMS5naWYwDQYJ 25 | KoZIhvcNAQEFBQADggEBACQuPyIJqXwUyFRWw9x5yDXgMW4zYFopQYOw/ItRY522 26 | O5BsySTh56BWS6mQB07XVfxmYUGAvRQDA5QHpmY8jIlNwSmN3s8RKo+fAtiNRlcL 27 | x/mWSfuMs3D/S6ev3D6+dpEMZtjrhOdctsarMKp8n/hPbwhAbg5hVjpkW5n8vz2y 28 | 0KxvvkA1AxpLwpVv7OlK17ttzIHw8bp9HTlHBU5s8bKz4a565V/a5HI0CSEv/+0y 29 | ko4/ghTnZc1CkmUngKKeFMSah/mT/xAh8XnE2l1AazFa8UKuYki1e+ArHaGZc4ix 30 | UYOtiRphwfuYQhRZ7qX9q2MMkCMI65XNK/SaFrAbbG0= 31 | -----END CERTIFICATE----- 32 | -------------------------------------------------------------------------------- /greentest/3.3/nullcert.pem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantix/gevent/71dd2d4d1d3332ed87f79c19d54d97bdcacdcf6d/greentest/3.3/nullcert.pem -------------------------------------------------------------------------------- /greentest/3.3/subprocessdata/fd_status.py: -------------------------------------------------------------------------------- 1 | """When called as a script, print a comma-separated list of the open 2 | file descriptors on stdout.""" 3 | 4 | import errno 5 | import os 6 | 7 | try: 8 | _MAXFD = os.sysconf("SC_OPEN_MAX") 9 | except: 10 | _MAXFD = 256 11 | 12 | if __name__ == "__main__": 13 | fds = [] 14 | for fd in range(0, _MAXFD): 15 | try: 16 | st = os.fstat(fd) 17 | except OSError as e: 18 | if e.errno == errno.EBADF: 19 | continue 20 | raise 21 | # Ignore Solaris door files 22 | if st.st_mode & 0xF000 != 0xd000: 23 | fds.append(fd) 24 | print(','.join(map(str, fds))) 25 | -------------------------------------------------------------------------------- /greentest/3.3/subprocessdata/input_reader.py: -------------------------------------------------------------------------------- 1 | """When called as a script, consumes the input""" 2 | 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | for line in sys.stdin: 7 | pass 8 | -------------------------------------------------------------------------------- /greentest/3.3/subprocessdata/qcat.py: -------------------------------------------------------------------------------- 1 | """When ran as a script, simulates cat with no arguments.""" 2 | 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | for line in sys.stdin: 7 | sys.stdout.write(line) 8 | -------------------------------------------------------------------------------- /greentest/3.3/subprocessdata/qgrep.py: -------------------------------------------------------------------------------- 1 | """When called with a single argument, simulated fgrep with a single 2 | argument and no options.""" 3 | 4 | import sys 5 | 6 | if __name__ == "__main__": 7 | pattern = sys.argv[1] 8 | for line in sys.stdin: 9 | if pattern in line: 10 | sys.stdout.write(line) 11 | -------------------------------------------------------------------------------- /greentest/3.3/subprocessdata/sigchild_ignore.py: -------------------------------------------------------------------------------- 1 | import signal, subprocess, sys, time 2 | # On Linux this causes os.waitpid to fail with OSError as the OS has already 3 | # reaped our child process. The wait() passing the OSError on to the caller 4 | # and causing us to exit with an error is what we are testing against. 5 | signal.signal(signal.SIGCHLD, signal.SIG_IGN) 6 | subprocess.Popen([sys.executable, '-c', 'print("albatross")']).wait() 7 | # Also ensure poll() handles an errno.ECHILD appropriately. 8 | p = subprocess.Popen([sys.executable, '-c', 'print("albatross")']) 9 | num_polls = 0 10 | while p.poll() is None: 11 | # Waiting for the process to finish. 12 | time.sleep(0.01) # Avoid being a CPU busy loop. 13 | num_polls += 1 14 | if num_polls > 3000: 15 | raise RuntimeError('poll should have returned 0 within 30 seconds') 16 | -------------------------------------------------------------------------------- /greentest/3.3/version: -------------------------------------------------------------------------------- 1 | 3.3.5 2 | -------------------------------------------------------------------------------- /greentest/3.4/badcert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L 3 | opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH 4 | fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB 5 | AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU 6 | D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA 7 | IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM 8 | oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0 9 | ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/ 10 | loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j 11 | oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA 12 | z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq 13 | ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV 14 | q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU= 15 | -----END RSA PRIVATE KEY----- 16 | -----BEGIN CERTIFICATE----- 17 | Just bad cert data 18 | -----END CERTIFICATE----- 19 | -----BEGIN RSA PRIVATE KEY----- 20 | MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L 21 | opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH 22 | fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB 23 | AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU 24 | D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA 25 | IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM 26 | oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0 27 | ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/ 28 | loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j 29 | oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA 30 | z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq 31 | ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV 32 | q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU= 33 | -----END RSA PRIVATE KEY----- 34 | -----BEGIN CERTIFICATE----- 35 | Just bad cert data 36 | -----END CERTIFICATE----- 37 | -------------------------------------------------------------------------------- /greentest/3.4/keycert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANtb0+YrKuxevGpm 3 | LrjaUhZSgz6zFAmuGFmKmUbdjmfv9zSmmdsQIksK++jK0Be9LeZy20j6ahOfuVa0 4 | ufEmPoP7Fy4hXegKZR9cCWcIe/A6H2xWF1IIJLRTLaU8ol/I7T+um5HD5AwAwNPP 5 | USNU0Eegmvp+xxWu3NX2m1Veot85AgMBAAECgYA3ZdZ673X0oexFlq7AAmrutkHt 6 | CL7LvwrpOiaBjhyTxTeSNWzvtQBkIU8DOI0bIazA4UreAFffwtvEuPmonDb3F+Iq 7 | SMAu42XcGyVZEl+gHlTPU9XRX7nTOXVt+MlRRRxL6t9GkGfUAXI3XxJDXW3c0vBK 8 | UL9xqD8cORXOfE06rQJBAP8mEX1ERkR64Ptsoe4281vjTlNfIbs7NMPkUnrn9N/Y 9 | BLhjNIfQ3HFZG8BTMLfX7kCS9D593DW5tV4Z9BP/c6cCQQDcFzCcVArNh2JSywOQ 10 | ZfTfRbJg/Z5Lt9Fkngv1meeGNPgIMLN8Sg679pAOOWmzdMO3V706rNPzSVMME7E5 11 | oPIfAkEA8pDddarP5tCvTTgUpmTFbakm0KoTZm2+FzHcnA4jRh+XNTjTOv98Y6Ik 12 | eO5d1ZnKXseWvkZncQgxfdnMqqpj5wJAcNq/RVne1DbYlwWchT2Si65MYmmJ8t+F 13 | 0mcsULqjOnEMwf5e+ptq5LzwbyrHZYq5FNk7ocufPv/ZQrcSSC+cFwJBAKvOJByS 14 | x56qyGeZLOQlWS2JS3KJo59XuLFGqcbgN9Om9xFa41Yb4N9NvplFivsvZdw3m1Q/ 15 | SPIXQuT8RMPDVNQ= 16 | -----END PRIVATE KEY----- 17 | -----BEGIN CERTIFICATE----- 18 | MIICVDCCAb2gAwIBAgIJANfHOBkZr8JOMA0GCSqGSIb3DQEBBQUAMF8xCzAJBgNV 19 | BAYTAlhZMRcwFQYDVQQHEw5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9u 20 | IFNvZnR3YXJlIEZvdW5kYXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDAeFw0xMDEw 21 | MDgyMzAxNTZaFw0yMDEwMDUyMzAxNTZaMF8xCzAJBgNVBAYTAlhZMRcwFQYDVQQH 22 | Ew5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9uIFNvZnR3YXJlIEZvdW5k 23 | YXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAw 24 | gYkCgYEA21vT5isq7F68amYuuNpSFlKDPrMUCa4YWYqZRt2OZ+/3NKaZ2xAiSwr7 25 | 6MrQF70t5nLbSPpqE5+5VrS58SY+g/sXLiFd6AplH1wJZwh78DofbFYXUggktFMt 26 | pTyiX8jtP66bkcPkDADA089RI1TQR6Ca+n7HFa7c1fabVV6i3zkCAwEAAaMYMBYw 27 | FAYDVR0RBA0wC4IJbG9jYWxob3N0MA0GCSqGSIb3DQEBBQUAA4GBAHPctQBEQ4wd 28 | BJ6+JcpIraopLn8BGhbjNWj40mmRqWB/NAWF6M5ne7KpGAu7tLeG4hb1zLaldK8G 29 | lxy2GPSRF6LFS48dpEj2HbMv2nvv6xxalDMJ9+DicWgAKTQ6bcX2j3GUkCR0g/T1 30 | CRlNBAAlvhKzO7Clpf9l0YKBEfraJByX 31 | -----END CERTIFICATE----- 32 | -------------------------------------------------------------------------------- /greentest/3.4/nokia.pem: -------------------------------------------------------------------------------- 1 | # Certificate for projects.developer.nokia.com:443 (see issue 13034) 2 | -----BEGIN CERTIFICATE----- 3 | MIIFLDCCBBSgAwIBAgIQLubqdkCgdc7lAF9NfHlUmjANBgkqhkiG9w0BAQUFADCB 4 | vDELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL 5 | ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTswOQYDVQQLEzJUZXJtcyBvZiB1c2Ug 6 | YXQgaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL3JwYSAoYykxMDE2MDQGA1UEAxMt 7 | VmVyaVNpZ24gQ2xhc3MgMyBJbnRlcm5hdGlvbmFsIFNlcnZlciBDQSAtIEczMB4X 8 | DTExMDkyMTAwMDAwMFoXDTEyMDkyMDIzNTk1OVowcTELMAkGA1UEBhMCRkkxDjAM 9 | BgNVBAgTBUVzcG9vMQ4wDAYDVQQHFAVFc3BvbzEOMAwGA1UEChQFTm9raWExCzAJ 10 | BgNVBAsUAkJJMSUwIwYDVQQDFBxwcm9qZWN0cy5kZXZlbG9wZXIubm9raWEuY29t 11 | MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCr92w1bpHYSYxUEx8N/8Iddda2 12 | lYi+aXNtQfV/l2Fw9Ykv3Ipw4nLeGTj18FFlAZgMdPRlgrzF/NNXGw/9l3/qKdow 13 | CypkQf8lLaxb9Ze1E/KKmkRJa48QTOqvo6GqKuTI6HCeGlG1RxDb8YSKcQWLiytn 14 | yj3Wp4MgRQO266xmMQIDAQABo4IB9jCCAfIwQQYDVR0RBDowOIIccHJvamVjdHMu 15 | ZGV2ZWxvcGVyLm5va2lhLmNvbYIYcHJvamVjdHMuZm9ydW0ubm9raWEuY29tMAkG 16 | A1UdEwQCMAAwCwYDVR0PBAQDAgWgMEEGA1UdHwQ6MDgwNqA0oDKGMGh0dHA6Ly9T 17 | VlJJbnRsLUczLWNybC52ZXJpc2lnbi5jb20vU1ZSSW50bEczLmNybDBEBgNVHSAE 18 | PTA7MDkGC2CGSAGG+EUBBxcDMCowKAYIKwYBBQUHAgEWHGh0dHBzOi8vd3d3LnZl 19 | cmlzaWduLmNvbS9ycGEwKAYDVR0lBCEwHwYJYIZIAYb4QgQBBggrBgEFBQcDAQYI 20 | KwYBBQUHAwIwcgYIKwYBBQUHAQEEZjBkMCQGCCsGAQUFBzABhhhodHRwOi8vb2Nz 21 | cC52ZXJpc2lnbi5jb20wPAYIKwYBBQUHMAKGMGh0dHA6Ly9TVlJJbnRsLUczLWFp 22 | YS52ZXJpc2lnbi5jb20vU1ZSSW50bEczLmNlcjBuBggrBgEFBQcBDARiMGChXqBc 23 | MFowWDBWFglpbWFnZS9naWYwITAfMAcGBSsOAwIaBBRLa7kolgYMu9BSOJsprEsH 24 | iyEFGDAmFiRodHRwOi8vbG9nby52ZXJpc2lnbi5jb20vdnNsb2dvMS5naWYwDQYJ 25 | KoZIhvcNAQEFBQADggEBACQuPyIJqXwUyFRWw9x5yDXgMW4zYFopQYOw/ItRY522 26 | O5BsySTh56BWS6mQB07XVfxmYUGAvRQDA5QHpmY8jIlNwSmN3s8RKo+fAtiNRlcL 27 | x/mWSfuMs3D/S6ev3D6+dpEMZtjrhOdctsarMKp8n/hPbwhAbg5hVjpkW5n8vz2y 28 | 0KxvvkA1AxpLwpVv7OlK17ttzIHw8bp9HTlHBU5s8bKz4a565V/a5HI0CSEv/+0y 29 | ko4/ghTnZc1CkmUngKKeFMSah/mT/xAh8XnE2l1AazFa8UKuYki1e+ArHaGZc4ix 30 | UYOtiRphwfuYQhRZ7qX9q2MMkCMI65XNK/SaFrAbbG0= 31 | -----END CERTIFICATE----- 32 | -------------------------------------------------------------------------------- /greentest/3.4/nullcert.pem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantix/gevent/71dd2d4d1d3332ed87f79c19d54d97bdcacdcf6d/greentest/3.4/nullcert.pem -------------------------------------------------------------------------------- /greentest/3.4/subprocessdata/fd_status.py: -------------------------------------------------------------------------------- 1 | """When called as a script, print a comma-separated list of the open 2 | file descriptors on stdout. 3 | 4 | Usage: 5 | fd_stats.py: check all file descriptors 6 | fd_status.py fd1 fd2 ...: check only specified file descriptors 7 | """ 8 | 9 | import errno 10 | import os 11 | import stat 12 | import sys 13 | 14 | if __name__ == "__main__": 15 | fds = [] 16 | if len(sys.argv) == 1: 17 | try: 18 | _MAXFD = os.sysconf("SC_OPEN_MAX") 19 | except: 20 | _MAXFD = 256 21 | test_fds = range(0, _MAXFD) 22 | else: 23 | test_fds = map(int, sys.argv[1:]) 24 | for fd in test_fds: 25 | try: 26 | st = os.fstat(fd) 27 | except OSError as e: 28 | if e.errno == errno.EBADF: 29 | continue 30 | raise 31 | # Ignore Solaris door files 32 | if not stat.S_ISDOOR(st.st_mode): 33 | fds.append(fd) 34 | print(','.join(map(str, fds))) 35 | -------------------------------------------------------------------------------- /greentest/3.4/subprocessdata/input_reader.py: -------------------------------------------------------------------------------- 1 | """When called as a script, consumes the input""" 2 | 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | for line in sys.stdin: 7 | pass 8 | -------------------------------------------------------------------------------- /greentest/3.4/subprocessdata/qcat.py: -------------------------------------------------------------------------------- 1 | """When ran as a script, simulates cat with no arguments.""" 2 | 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | for line in sys.stdin: 7 | sys.stdout.write(line) 8 | -------------------------------------------------------------------------------- /greentest/3.4/subprocessdata/qgrep.py: -------------------------------------------------------------------------------- 1 | """When called with a single argument, simulated fgrep with a single 2 | argument and no options.""" 3 | 4 | import sys 5 | 6 | if __name__ == "__main__": 7 | pattern = sys.argv[1] 8 | for line in sys.stdin: 9 | if pattern in line: 10 | sys.stdout.write(line) 11 | -------------------------------------------------------------------------------- /greentest/3.4/subprocessdata/sigchild_ignore.py: -------------------------------------------------------------------------------- 1 | import signal, subprocess, sys, time 2 | # On Linux this causes os.waitpid to fail with OSError as the OS has already 3 | # reaped our child process. The wait() passing the OSError on to the caller 4 | # and causing us to exit with an error is what we are testing against. 5 | signal.signal(signal.SIGCHLD, signal.SIG_IGN) 6 | subprocess.Popen([sys.executable, '-c', 'print("albatross")']).wait() 7 | # Also ensure poll() handles an errno.ECHILD appropriately. 8 | p = subprocess.Popen([sys.executable, '-c', 'print("albatross")']) 9 | num_polls = 0 10 | while p.poll() is None: 11 | # Waiting for the process to finish. 12 | time.sleep(0.01) # Avoid being a CPU busy loop. 13 | num_polls += 1 14 | if num_polls > 3000: 15 | raise RuntimeError('poll should have returned 0 within 30 seconds') 16 | -------------------------------------------------------------------------------- /greentest/3.4/version: -------------------------------------------------------------------------------- 1 | 3.4.0 2 | -------------------------------------------------------------------------------- /greentest/badcert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L 3 | opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH 4 | fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB 5 | AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU 6 | D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA 7 | IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM 8 | oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0 9 | ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/ 10 | loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j 11 | oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA 12 | z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq 13 | ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV 14 | q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU= 15 | -----END RSA PRIVATE KEY----- 16 | -----BEGIN CERTIFICATE----- 17 | Just bad cert data 18 | -----END CERTIFICATE----- 19 | -----BEGIN RSA PRIVATE KEY----- 20 | MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L 21 | opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH 22 | fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB 23 | AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU 24 | D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA 25 | IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM 26 | oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0 27 | ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/ 28 | loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j 29 | oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA 30 | z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq 31 | ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV 32 | q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU= 33 | -----END RSA PRIVATE KEY----- 34 | -----BEGIN CERTIFICATE----- 35 | Just bad cert data 36 | -----END CERTIFICATE----- 37 | -------------------------------------------------------------------------------- /greentest/bench_sendall.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | from __future__ import print_function 3 | import time 4 | from gevent import socket 5 | from gevent.server import StreamServer 6 | 7 | 8 | def recvall(socket, addr): 9 | while socket.recv(4096): 10 | pass 11 | 12 | 13 | def main(): 14 | server = StreamServer(("127.0.0.1", 0), recvall) 15 | server.start() 16 | 17 | length = 50 * 0x100000 18 | data = b"x" * length 19 | 20 | spent_total = 0 21 | N = 10 22 | 23 | conn = socket.create_connection((server.server_host, server.server_port)) 24 | for i in range(N): 25 | start = time.time() 26 | conn.sendall(data) 27 | spent = time.time() - start 28 | print("%.2f MB/s" % (length / spent / 0x100000)) 29 | spent_total += spent 30 | 31 | print("~ %.2f MB/s" % (length * N / spent_total / 0x100000)) 32 | server.stop() 33 | 34 | 35 | if __name__ == "__main__": 36 | main() 37 | -------------------------------------------------------------------------------- /greentest/bench_sleep0.py: -------------------------------------------------------------------------------- 1 | """Benchmarking sleep(0) performance.""" 2 | from __future__ import print_function 3 | import sys 4 | from time import time 5 | try: 6 | xrange 7 | except NameError: 8 | xrange = range 9 | 10 | 11 | def noop(p): 12 | pass 13 | 14 | N = 100000 15 | ARG = 0 16 | 17 | 18 | def test(sleep, arg): 19 | start = time() 20 | for _ in xrange(N): 21 | sleep(arg) 22 | return time() - start 23 | 24 | 25 | def bench_none(): 26 | test(noop) 27 | 28 | 29 | def bench_gevent(arg=0): 30 | import gevent 31 | from gevent import sleep 32 | delta = test(sleep, arg) 33 | print('gevent %s (%s): sleep(%r): %.1f microseconds' % (gevent.__version__, gevent.__file__, arg, delta * 1000000. / N)) 34 | 35 | 36 | def bench_eventlet(arg): 37 | try: 38 | import eventlet 39 | except ImportError as ex: 40 | sys.stderr.write('Failed to import eventlet: %s\n' % ex) 41 | return 42 | from eventlet.api import sleep 43 | delta = test(sleep, arg) 44 | print('eventlet %s (%s): sleep(%r): %.1f microseconds' % (eventlet.__version__, eventlet.__file__, arg, delta * 1000000. / N)) 45 | 46 | 47 | def main(): 48 | global N 49 | for arg in [0, -1, 0.00001]: 50 | bench_gevent(arg) 51 | bench_eventlet(arg) 52 | N = 1000 53 | bench_gevent(0.001) 54 | bench_eventlet(0.001) 55 | 56 | 57 | if __name__ == '__main__': 58 | main() 59 | -------------------------------------------------------------------------------- /greentest/keycert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L 3 | opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH 4 | fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB 5 | AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU 6 | D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA 7 | IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM 8 | oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0 9 | ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/ 10 | loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j 11 | oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA 12 | z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq 13 | ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV 14 | q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU= 15 | -----END RSA PRIVATE KEY----- 16 | -----BEGIN CERTIFICATE----- 17 | MIICpzCCAhCgAwIBAgIJAP+qStv1cIGNMA0GCSqGSIb3DQEBBQUAMIGJMQswCQYD 18 | VQQGEwJVUzERMA8GA1UECBMIRGVsYXdhcmUxEzARBgNVBAcTCldpbG1pbmd0b24x 19 | IzAhBgNVBAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMQwwCgYDVQQLEwNT 20 | U0wxHzAdBgNVBAMTFnNvbWVtYWNoaW5lLnB5dGhvbi5vcmcwHhcNMDcwODI3MTY1 21 | NDUwWhcNMTMwMjE2MTY1NDUwWjCBiTELMAkGA1UEBhMCVVMxETAPBgNVBAgTCERl 22 | bGF3YXJlMRMwEQYDVQQHEwpXaWxtaW5ndG9uMSMwIQYDVQQKExpQeXRob24gU29m 23 | dHdhcmUgRm91bmRhdGlvbjEMMAoGA1UECxMDU1NMMR8wHQYDVQQDExZzb21lbWFj 24 | aGluZS5weXRob24ub3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8ddrh 25 | m+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9LopdJhTvbGfEj0DQs1IE8 26 | M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVHfhi/VwovESJlaBOp+WMn 27 | fhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQABoxUwEzARBglghkgBhvhC 28 | AQEEBAMCBkAwDQYJKoZIhvcNAQEFBQADgYEAF4Q5BVqmCOLv1n8je/Jw9K669VXb 29 | 08hyGzQhkemEBYQd6fzQ9A/1ZzHkJKb1P6yreOLSEh4KcxYPyrLRC1ll8nr5OlCx 30 | CMhKkTnR6qBsdNV0XtdU2+N25hqW+Ma4ZeqsN/iiJVCGNOZGnvQuvCAGWF8+J/f/ 31 | iHkC6gGdBJhogs4= 32 | -----END CERTIFICATE----- 33 | -------------------------------------------------------------------------------- /greentest/monkey_test.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | 4 | kwargs = {} 5 | 6 | if sys.argv[1] == '--Event': 7 | kwargs['Event'] = True 8 | del sys.argv[1] 9 | else: 10 | kwargs['Event'] = False 11 | 12 | test_filename = sys.argv[1] 13 | del sys.argv[1] 14 | 15 | print('Running with patch_all(%s): %s' % (','.join('%s=%r' % x for x in kwargs.items()), test_filename)) 16 | 17 | from gevent import monkey; monkey.patch_all(**kwargs) 18 | 19 | from patched_tests_setup import disable_tests_in_source 20 | try: 21 | from test import support 22 | except ImportError: 23 | from test import test_support as support 24 | support.is_resource_enabled = lambda *args: True 25 | del support.use_resources 26 | 27 | if sys.version_info[:2] <= (2, 6): 28 | support.TESTFN += '_%s' % os.getpid() 29 | 30 | __file__ = os.path.join(os.getcwd(), test_filename) 31 | 32 | test_name = os.path.splitext(test_filename)[0] 33 | module_source = open(test_filename).read() 34 | module_source = disable_tests_in_source(module_source, test_name) 35 | module_code = compile(module_source, test_filename, 'exec') 36 | exec(module_code, globals()) 37 | -------------------------------------------------------------------------------- /greentest/nullcert.pem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantix/gevent/71dd2d4d1d3332ed87f79c19d54d97bdcacdcf6d/greentest/nullcert.pem -------------------------------------------------------------------------------- /greentest/sha256.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIFxzCCA6+gAwIBAgIJALnlnf5uzTkIMA0GCSqGSIb3DQEBCwUAMEsxCzAJBgNV 3 | BAYTAkRFMRcwFQYDVQQKEw5zY2hva29rZWtzLm9yZzEjMCEGCSqGSIb3DQEJARYU 4 | aGFubm9Ac2Nob2tva2Vrcy5vcmcwHhcNMTAwMTI3MDAyMTI1WhcNMjAwMTI1MDAy 5 | MTI1WjBLMQswCQYDVQQGEwJERTEXMBUGA1UEChMOc2Nob2tva2Vrcy5vcmcxIzAh 6 | BgkqhkiG9w0BCQEWFGhhbm5vQHNjaG9rb2tla3Mub3JnMIICIjANBgkqhkiG9w0B 7 | AQEFAAOCAg8AMIICCgKCAgEApJ4ODPwEooMW35dQPlBqdvcfkEvjhcsA7jmJfFqN 8 | e/1T34zT44X9+KnMBSG2InacbD7eyFgjfaENFsZ87YkEBDIFZ/SHotLJZORQ8PUj 9 | YoxPG4mjKN+yL2WthNcYbRyJreTbbDroNMuw6tkTSxeSXyYFQrKMCUfErVbZa/d5 10 | RvfFVk+Au9dVUFhed/Stn5cv+a0ffvpyA7ygihm1kMFICbvPeI0846tmC2Ph7rM5 11 | pYQyNBDOVpULODTk5Wu6jiiJJygvJWCZ1FdpsdBs5aKWHWdRhX++quGuflTTjH5d 12 | qaIka4op9H7XksYphTDXmV+qHnva5jbPogwutDQcVsGBQcJaLmQqhsQK13bf4khE 13 | iWJvfBLfHn8OOpY25ZwwuigJIwifNCxQeeT1FrLmyuYNhz2phPpzx065kqSUSR+A 14 | Iw8DPE6e65UqMDKqZnID3dQeiQaFrHEV+Ibo0U/tD0YSBw5p33TMh0Es33IBWMac 15 | m7x4hIFWdhl8W522u6qOrTswY3s8vB7blNWqMc9n7oWH8ybFf7EgKeDVtEN9AyBE 16 | 0WotXIEZWI+WvDbU1ACJXau9sQhYP/eerg7Zwr3iGUy4IQ5oUJibnjtcE+z8zmDN 17 | pE6YcMCLJyLjXiQ3iHG9mNXzw7wPnslTbEEEukrfSlHGgW8Dm+VrNyW0JUM1bntx 18 | vbMCAwEAAaOBrTCBqjAdBgNVHQ4EFgQUCedv7pDTuXtCxm4HTw9hUtrTvsowewYD 19 | VR0jBHQwcoAUCedv7pDTuXtCxm4HTw9hUtrTvsqhT6RNMEsxCzAJBgNVBAYTAkRF 20 | MRcwFQYDVQQKEw5zY2hva29rZWtzLm9yZzEjMCEGCSqGSIb3DQEJARYUaGFubm9A 21 | c2Nob2tva2Vrcy5vcmeCCQC55Z3+bs05CDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3 22 | DQEBCwUAA4ICAQBHKAxA7WA/MEFjet03K8ouzEOr6Jrk2fZOuRhoDZ+9gr4FtaJB 23 | P3Hh5D00kuSOvDnwsvCohxeNd1KTMAwVmVoH+NZkHERn3UXniUENlp18koI1ehlr 24 | CZbXbzzE9Te9BelliSFA63q0cq0yJN1x9GyabU34XkAouCAmOqfSpKNZWZHGBHPF 25 | bbYnZrHEMcsye6vKeTOcg1GqUHGrQM2WK0QaOwnCQv2RblI9VN+SeRoUJ44qTXdW 26 | TwIYStsIPesacNcAQTStnHgKqIPx4zCwdx5xo8zONbXJfocqwyFqiAofvb9dN1nW 27 | g1noVBcXB+oRBZW5CjFw87U88itq39i9+BWl835DWLBW2pVmx1QTLGv0RNgs/xVx 28 | mWnjH4nNHvrjn6pRmqHZTk/SS0Hkl2qtDsynVxIl8EiMTfWSU3DBTuD2J/RSzuOE 29 | eKtAbaoXkXE31jCl4FEZLITIZd8UkXacb9rN304tAK92L76JOAV+xOZxFRipmvx4 30 | +A9qQXgLhtP4VaDajb44V/kCKPSA0Vm3apehke9Wl8dDtagfos1e6MxSu3EVLXRF 31 | SP2U777V77pdMSd0f/7cerKn5FjrxW1v1FaP1oIGniMk4qQNTgA/jvvhjybsPlVA 32 | jsfnhWGbh1voJa0RQcMiRMsxpw2P1KNOEu37W2eq/vFghVztZJQUmb5iNw== 33 | -----END CERTIFICATE----- 34 | -------------------------------------------------------------------------------- /greentest/six.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | PY3 = sys.version_info[0] >= 3 4 | 5 | if PY3: 6 | advance_iterator = next 7 | else: 8 | def advance_iterator(it): 9 | return it.next() 10 | 11 | if PY3: 12 | import builtins 13 | exec_ = getattr(builtins, "exec") 14 | 15 | def reraise(tp, value, tb=None): 16 | if value.__traceback__ is not tb: 17 | raise value.with_traceback(tb) 18 | raise value 19 | 20 | xrange = range 21 | string_types = str, 22 | text_type = str 23 | 24 | else: 25 | def exec_(code, globs=None, locs=None): 26 | """Execute code in a namespace.""" 27 | if globs is None: 28 | frame = sys._getframe(1) 29 | globs = frame.f_globals 30 | if locs is None: 31 | locs = frame.f_locals 32 | del frame 33 | elif locs is None: 34 | locs = globs 35 | exec("""exec code in globs, locs""") 36 | 37 | import __builtin__ as builtins 38 | xrange = builtins.xrange 39 | string_types = builtins.basestring, 40 | text_type = builtins.unicode 41 | -------------------------------------------------------------------------------- /greentest/test__GreenletExit.py: -------------------------------------------------------------------------------- 1 | from gevent import GreenletExit 2 | 3 | assert issubclass(GreenletExit, BaseException) 4 | assert not issubclass(GreenletExit, Exception) 5 | -------------------------------------------------------------------------------- /greentest/test___monkey_patching.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | import glob 4 | import util 5 | import atexit 6 | # subprocess: include in subprocess tests 7 | 8 | 9 | TIMEOUT = 120 10 | directory = '%s.%s' % sys.version_info[:2] 11 | if hasattr(sys, 'pypy_version_info'): 12 | directory += 'pypy' 13 | version = '%s.%s.%s' % sys.version_info[:3] 14 | 15 | 16 | def get_absolute_pythonpath(): 17 | paths = [os.path.abspath(p) for p in os.environ.get('PYTHONPATH', '').split(os.pathsep)] 18 | return os.pathsep.join(paths) 19 | 20 | 21 | def TESTRUNNER(tests=None): 22 | if not os.path.exists(directory): 23 | return 24 | preferred_version = open(os.path.join(directory, 'version')).read().strip() 25 | if preferred_version != version: 26 | util.log('WARNING: The tests in %s/ are from version %s and your Python is %s', directory, preferred_version, version) 27 | 28 | if not tests: 29 | tests = sorted(glob.glob('%s/test_*.py' % directory)) 30 | 31 | PYTHONPATH = (os.getcwd() + os.pathsep + get_absolute_pythonpath()).rstrip(':') 32 | 33 | tests = [os.path.basename(x) for x in tests] 34 | options = {'cwd': directory, 35 | 'timeout': TIMEOUT, 36 | 'setenv': {'PYTHONPATH': PYTHONPATH}} 37 | 38 | if tests: 39 | atexit.register(os.system, 'rm -f */@test*') 40 | 41 | for filename in tests: 42 | yield [sys.executable, '-u', '-m', 'monkey_test', filename], options.copy() 43 | yield [sys.executable, '-u', '-m', 'monkey_test', '--Event', filename], options.copy() 44 | 45 | 46 | def main(): 47 | import testrunner 48 | return testrunner.run_many(list(TESTRUNNER(sys.argv[1:]))) 49 | 50 | 51 | if __name__ == '__main__': 52 | main() 53 | -------------------------------------------------------------------------------- /greentest/test__ares_host_result.py: -------------------------------------------------------------------------------- 1 | import pickle 2 | import greentest 3 | from gevent.ares import ares_host_result 4 | 5 | 6 | class TestPickle(greentest.TestCase): 7 | # Issue 104: ares.ares_host_result unpickleable 8 | 9 | def _test(self, protocol): 10 | r = ares_host_result('family', ('arg1', 'arg2', )) 11 | dumped = pickle.dumps(r, protocol) 12 | loaded = pickle.loads(dumped) 13 | assert r == loaded, (r, loaded) 14 | assert r.family == loaded.family, (r, loaded) 15 | 16 | def test0(self): 17 | return self._test(0) 18 | 19 | def test1(self): 20 | return self._test(1) 21 | 22 | def test2(self): 23 | return self._test(2) 24 | 25 | if pickle.HIGHEST_PROTOCOL == 3: 26 | def test3(self): 27 | return self._test(3) 28 | else: 29 | assert pickle.HIGHEST_PROTOCOL == 2, pickle.HIGHEST_PROTOCOL 30 | 31 | 32 | if __name__ == '__main__': 33 | greentest.main() 34 | -------------------------------------------------------------------------------- /greentest/test__core_async.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | import gevent 3 | import gevent.core 4 | import time 5 | try: 6 | import thread 7 | except ImportError: 8 | import _thread as thread 9 | 10 | 11 | hub = gevent.get_hub() 12 | watcher = hub.loop.async() 13 | 14 | gevent.spawn_later(0.1, thread.start_new_thread, watcher.send, ()) 15 | 16 | start = time.time() 17 | 18 | with gevent.Timeout(0.3): 19 | hub.wait(watcher) 20 | 21 | print('Watcher %r reacted after %.6f seconds' % (watcher, time.time() - start - 0.1)) 22 | -------------------------------------------------------------------------------- /greentest/test__core_callback.py: -------------------------------------------------------------------------------- 1 | import gevent 2 | from gevent.hub import get_hub 3 | 4 | called = [] 5 | 6 | 7 | def f(): 8 | called.append(1) 9 | 10 | 11 | def main(): 12 | loop = get_hub().loop 13 | x = loop.run_callback(f) 14 | 15 | assert x, x 16 | gevent.sleep(0) 17 | assert called == [1], called 18 | assert not x, (x, bool(x)) 19 | 20 | x = loop.run_callback(f) 21 | assert x, x 22 | x.stop() 23 | assert not x, x 24 | gevent.sleep(0) 25 | assert called == [1], called 26 | assert not x, x 27 | 28 | 29 | if __name__ == '__main__': 30 | called[:] = [] 31 | main() 32 | -------------------------------------------------------------------------------- /greentest/test__core_loop_run.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | import sys 3 | from gevent import core, signal 4 | loop = core.loop() 5 | 6 | 7 | signal = signal(2, sys.stderr.write, 'INTERRUPT!') 8 | 9 | print('must exit immediatelly...') 10 | loop.run() # must exit immediatelly 11 | print('...and once more...') 12 | loop.run() # repeating does not fail 13 | print('..done') 14 | 15 | print('must exit after 0.5 seconds.') 16 | timer = loop.timer(0.5) 17 | timer.start(lambda: None) 18 | loop.run() 19 | 20 | del loop 21 | -------------------------------------------------------------------------------- /greentest/test__core_stat.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | import gevent 3 | import gevent.core 4 | import os 5 | import time 6 | 7 | 8 | filename = 'tmp.test__core_stat.%s' % os.getpid() 9 | 10 | hub = gevent.get_hub() 11 | 12 | DELAY = 0.5 13 | 14 | EV_USE_INOTIFY = getattr(gevent.core, 'EV_USE_INOTIFY', None) 15 | 16 | try: 17 | open(filename, 'wb', buffering=0).close() 18 | assert os.path.exists(filename), filename 19 | 20 | def write(): 21 | f = open(filename, 'wb', buffering=0) 22 | f.write(b'x') 23 | f.close() 24 | 25 | greenlet = gevent.spawn_later(DELAY, write) 26 | watcher = hub.loop.stat(filename.encode()) 27 | 28 | start = time.time() 29 | 30 | with gevent.Timeout(5 + DELAY + 0.5): 31 | hub.wait(watcher) 32 | 33 | reaction = time.time() - start - DELAY 34 | print('Watcher %s reacted after %.4f seconds (write)' % (watcher, reaction)) 35 | if reaction >= DELAY and EV_USE_INOTIFY: 36 | print('WARNING: inotify failed (write)') 37 | assert reaction >= 0.0, 'Watcher %s reacted too early (write): %.3fs' % (watcher, reaction) 38 | assert watcher.attr is not None, watcher.attr 39 | assert watcher.prev is not None, watcher.prev 40 | 41 | greenlet.join() 42 | gevent.spawn_later(DELAY, os.unlink, filename) 43 | 44 | start = time.time() 45 | 46 | with gevent.Timeout(5 + DELAY + 0.5): 47 | hub.wait(watcher) 48 | 49 | reaction = time.time() - start - DELAY 50 | print('Watcher %s reacted after %.4f seconds (unlink)' % (watcher, reaction)) 51 | if reaction >= DELAY and EV_USE_INOTIFY: 52 | print('WARNING: inotify failed (unlink)') 53 | assert reaction >= 0.0, 'Watcher %s reacted too early (unlink): %.3fs' % (watcher, reaction) 54 | assert watcher.attr is None, watcher.attr 55 | assert watcher.prev is not None, watcher.prev 56 | 57 | finally: 58 | if os.path.exists(filename): 59 | os.unlink(filename) 60 | -------------------------------------------------------------------------------- /greentest/test__core_timer.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | from gevent import core 3 | 4 | called = [] 5 | 6 | 7 | def f(): 8 | called.append(1) 9 | 10 | 11 | def main(): 12 | loop = core.loop(default=True) 13 | x = loop.timer(0.001) 14 | x.start(f) 15 | 16 | assert x.active, x.pending 17 | try: 18 | x.priority = 1 19 | raise AssertionError('must not be able to change priority of active watcher') 20 | except AttributeError: 21 | pass 22 | loop.run() 23 | assert x.pending == 0, x.pending 24 | assert called == [1], called 25 | assert x.callback is None, x.callback 26 | assert x.args is None, x.args 27 | assert x.priority == 0, x 28 | x.priority = 1 29 | assert x.priority == 1, x 30 | x.stop() 31 | 32 | 33 | if __name__ == '__main__': 34 | import sys 35 | gettotalrefcount = getattr(sys, 'gettotalrefcount', None) 36 | called[:] = [] 37 | if gettotalrefcount is not None: 38 | print(gettotalrefcount()) 39 | main() 40 | called[:] = [] 41 | if gettotalrefcount is not None: 42 | print(gettotalrefcount()) 43 | -------------------------------------------------------------------------------- /greentest/test__destroy.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | import gevent 3 | # Loop of initial Hub is default loop. 4 | hub = gevent.get_hub() 5 | assert hub.loop.default, hub 6 | 7 | # Destroy hub. Does not destroy default loop if not explicitly told to. 8 | hub.destroy() 9 | hub = gevent.get_hub() 10 | assert hub.loop.default, hub 11 | 12 | saved_loop = hub.loop 13 | # Destroy hub including default loop. 14 | hub.destroy(destroy_loop=True) 15 | assert saved_loop.fileno() is None, saved_loop 16 | print(hub, saved_loop) 17 | 18 | # Create new hub and explicitly request creation of a new default loop. 19 | hub = gevent.get_hub(default=True) 20 | assert hub.loop.default, hub 21 | 22 | # Destroy hub including default loop. 23 | hub.destroy(destroy_loop=True) 24 | 25 | # Create new non-default loop in new hub. 26 | hub = gevent.get_hub() 27 | assert not hub.loop.default, hub 28 | hub.destroy() 29 | -------------------------------------------------------------------------------- /greentest/test__doctests.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | import sys 3 | import os 4 | import re 5 | import doctest 6 | import unittest 7 | import traceback 8 | import gevent 9 | from gevent import socket 10 | from greentest import walk_modules 11 | 12 | # Ignore tracebacks: ZeroDivisionError 13 | 14 | 15 | def myfunction(*args, **kwargs): 16 | pass 17 | 18 | 19 | if __name__ == '__main__': 20 | cwd = os.getcwd() 21 | try: 22 | allowed_modules = sys.argv[1:] 23 | sys.path.append('.') 24 | base = os.path.dirname(gevent.__file__) 25 | print(base) 26 | os.chdir('..') 27 | 28 | globs = {'myfunction': myfunction, 'gevent': gevent, 'socket': socket} 29 | 30 | modules = set() 31 | 32 | def add_module(name, path): 33 | if allowed_modules and name not in allowed_modules: 34 | return 35 | modules.add((name, path)) 36 | 37 | for path, module in walk_modules(): 38 | add_module(module, path) 39 | add_module('setup', 'setup.py') 40 | 41 | if not modules: 42 | sys.exit('No modules found matching %s' % ' '.join(allowed_modules)) 43 | 44 | suite = unittest.TestSuite() 45 | tests_count = 0 46 | modules_count = 0 47 | for m, path in modules: 48 | if re.search('^\s*>>> ', open(path).read(), re.M): 49 | try: 50 | s = doctest.DocTestSuite(m, extraglobs=globs) 51 | print('%s (from %s): %s tests' % (m, path, len(s._tests))) 52 | suite.addTest(s) 53 | modules_count += 1 54 | tests_count += len(s._tests) 55 | except Exception: 56 | traceback.print_exc() 57 | sys.stderr.write('Failed to process %s\n\n' % path) 58 | print('Total: %s tests in %s modules' % (tests_count, modules_count)) 59 | runner = unittest.TextTestRunner(verbosity=2) 60 | runner.run(suite) 61 | finally: 62 | os.chdir(cwd) 63 | -------------------------------------------------------------------------------- /greentest/test__environ.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import gevent 4 | import subprocess 5 | 6 | if sys.argv[1:] == []: 7 | os.environ['GEVENT_BACKEND'] = 'select' 8 | popen = subprocess.Popen([sys.executable, 'test__environ.py', '1']) 9 | assert popen.wait() == 0, popen.poll() 10 | else: 11 | hub = gevent.get_hub() 12 | assert hub.loop.backend == 'select', hub.loop.backend 13 | -------------------------------------------------------------------------------- /greentest/test__example_echoserver.py: -------------------------------------------------------------------------------- 1 | from gevent.socket import create_connection, timeout 2 | from unittest import main 3 | import gevent 4 | 5 | import util 6 | 7 | 8 | class Test(util.TestServer): 9 | server = 'echoserver.py' 10 | 11 | def _run_all_tests(self): 12 | def test_client(message): 13 | sock = create_connection(('127.0.0.1', 6000)) 14 | conn = sock.makefile('rwb', 1) 15 | welcome = conn.readline() 16 | assert b'Welcome' in welcome, repr(welcome) 17 | conn.write(message) 18 | received = conn.read(len(message)) 19 | self.assertEqual(received, message) 20 | if hasattr(conn, '_sock'): 21 | conn._sock.settimeout(0.1) 22 | else: 23 | sock.settimeout(0.1) 24 | 25 | self.assertRaises(timeout, conn.read, 1) 26 | conn.close() 27 | sock.close() 28 | client1 = gevent.spawn(test_client, b'hello\r\n') 29 | client2 = gevent.spawn(test_client, b'world\r\n') 30 | gevent.joinall([client1, client2], raise_error=True) 31 | 32 | 33 | if __name__ == '__main__': 34 | main() 35 | -------------------------------------------------------------------------------- /greentest/test__example_udp_client.py: -------------------------------------------------------------------------------- 1 | from gevent import monkey; monkey.patch_all(subprocess=True) 2 | import sys 3 | from gevent.server import DatagramServer 4 | from unittest import TestCase, main 5 | from util import run 6 | 7 | 8 | class Test_udp_client(TestCase): 9 | 10 | def test(self): 11 | log = [] 12 | 13 | def handle(message, address): 14 | log.append(message) 15 | server.sendto(b'reply-from-server', address) 16 | 17 | server = DatagramServer('127.0.0.1:9000', handle) 18 | server.start() 19 | try: 20 | run([sys.executable, '-u', 'udp_client.py', 'Test_udp_client'], timeout=10, cwd='../examples/') 21 | finally: 22 | server.close() 23 | self.assertEqual(log, [b'Test_udp_client']) 24 | 25 | 26 | if __name__ == '__main__': 27 | main() 28 | -------------------------------------------------------------------------------- /greentest/test__example_udp_server.py: -------------------------------------------------------------------------------- 1 | import socket 2 | from unittest import main 3 | import util 4 | 5 | 6 | class Test(util.TestServer): 7 | server = 'udp_server.py' 8 | 9 | def _run_all_tests(self): 10 | sock = socket.socket(type=socket.SOCK_DGRAM) 11 | sock.connect(('127.0.0.1', 9000)) 12 | sock.send(b'Test udp_server') 13 | data, address = sock.recvfrom(8192) 14 | self.assertEqual(data, b'Received 15 bytes') 15 | sock.close() 16 | 17 | 18 | if __name__ == '__main__': 19 | main() 20 | -------------------------------------------------------------------------------- /greentest/test__examples.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | import glob 4 | import time 5 | import util 6 | 7 | 8 | cwd = '../examples/' 9 | ignore = ['wsgiserver.py', 10 | 'wsgiserver_ssl.py', 11 | 'webproxy.py', 12 | 'webpy.py', 13 | 'unixsocket_server.py', 14 | 'unixsocket_client.py', 15 | 'psycopg2_pool.py', 16 | 'geventsendfile.py'] 17 | ignore += [x[14:] for x in glob.glob('test__example_*.py')] 18 | 19 | default_time_range = (2, 4) 20 | time_ranges = { 21 | 'concurrent_download.py': (0, 30), 22 | 'processes.py': (0, 4)} 23 | 24 | 25 | def main(tests=None): 26 | if not tests: 27 | tests = set(os.path.basename(x) for x in glob.glob('../examples/*.py')) 28 | tests = sorted(tests) 29 | 30 | failed = [] 31 | 32 | for filename in tests: 33 | if filename in ignore: 34 | continue 35 | min_time, max_time = time_ranges.get(filename, default_time_range) 36 | 37 | start = time.time() 38 | if util.run([sys.executable, '-u', filename], timeout=max_time, cwd=cwd): 39 | failed.append(filename) 40 | else: 41 | took = time.time() - start 42 | if took < min_time: 43 | util.log('! Failed example %s: exited too quickly, after %.1fs (expected %.1fs)', filename, took, min_time) 44 | failed.append(filename) 45 | 46 | if failed: 47 | util.log('! Failed examples:\n! - %s', '\n! - '.join(failed)) 48 | sys.exit(1) 49 | 50 | if not tests: 51 | sys.exit('No tests.') 52 | 53 | 54 | if __name__ == '__main__': 55 | main() 56 | -------------------------------------------------------------------------------- /greentest/test__exc_info.py: -------------------------------------------------------------------------------- 1 | import gevent 2 | import sys 3 | import greentest 4 | import six 5 | 6 | if not six.PY3: 7 | sys.exc_clear() 8 | 9 | 10 | class ExpectedError(Exception): 11 | pass 12 | 13 | 14 | expected_error = ExpectedError('expected exception in hello') 15 | 16 | 17 | def hello(): 18 | assert sys.exc_info() == (None, None, None), sys.exc_info() 19 | raise expected_error 20 | 21 | 22 | def hello2(): 23 | try: 24 | hello() 25 | except ExpectedError: 26 | pass 27 | 28 | 29 | error = Exception('hello') 30 | 31 | 32 | class Test(greentest.TestCase): 33 | 34 | def test1(self): 35 | try: 36 | raise error 37 | except: 38 | self.expect_one_error() 39 | g = gevent.spawn(hello) 40 | g.join() 41 | self.assert_error(ExpectedError, expected_error) 42 | if not isinstance(g.exception, ExpectedError): 43 | raise g.exception 44 | try: 45 | raise 46 | except Exception: 47 | ex = sys.exc_info()[1] 48 | assert ex is error, (ex, error) 49 | if six.PY3: 50 | ex.__traceback__ = None 51 | 52 | def test2(self): 53 | timer = gevent.get_hub().loop.timer(0) 54 | timer.start(hello2) 55 | gevent.sleep(0.1) 56 | assert sys.exc_info() == (None, None, None), sys.exc_info() 57 | if six.PY3: 58 | expected_error.__traceback__ = None 59 | 60 | 61 | if __name__ == '__main__': 62 | greentest.main() 63 | -------------------------------------------------------------------------------- /greentest/test__execmodules.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from greentest import walk_modules, BaseTestCase, main 3 | import six 4 | 5 | 6 | class TestExec(BaseTestCase): 7 | pass 8 | 9 | 10 | def make_exec_test(path, module): 11 | 12 | def test(self): 13 | #sys.stderr.write('%s %s\n' % (module, path)) 14 | f = open(path) 15 | src = f.read() 16 | f.close() 17 | six.exec_(src, {}) 18 | 19 | name = "test_" + module.replace(".", "_") 20 | test.__name__ = name 21 | setattr(TestExec, name, test) 22 | 23 | 24 | for path, module in walk_modules(): 25 | if sys.version_info[0] == 3 and path.endswith('2.py'): 26 | continue 27 | if sys.version_info[0] == 2 and path.endswith('3.py'): 28 | continue 29 | make_exec_test(path, module) 30 | 31 | 32 | if __name__ == '__main__': 33 | main() 34 | -------------------------------------------------------------------------------- /greentest/test__issue302monkey.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | 4 | if 'gevent' not in sys.modules: 5 | from subprocess import Popen 6 | args = [sys.executable, '-m', 'gevent.monkey', __file__] 7 | p = Popen(args) 8 | code = p.wait() 9 | assert code == 0, code 10 | 11 | else: 12 | import socket 13 | assert 'gevent' in repr(socket.socket), repr(socket.socket) 14 | assert __file__ == 'test__issue302monkey.py', repr(__file__) 15 | -------------------------------------------------------------------------------- /greentest/test__issue6.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | import sys 3 | 4 | 5 | if not sys.argv[1:]: 6 | from subprocess import Popen, PIPE 7 | p = Popen([sys.executable, __file__, 'subprocess'], stdin=PIPE, stdout=PIPE, stderr=PIPE) 8 | out, err = p.communicate(b'hello world\n') 9 | code = p.poll() 10 | assert p.poll() == 0, (out, err, code) 11 | assert out.strip() == '11 chars.', (out, err, code) 12 | assert err == '', (out, err, code) 13 | 14 | elif sys.argv[1:] == ['subprocess']: 15 | import gevent 16 | import gevent.monkey 17 | gevent.monkey.patch_all(sys=True) 18 | 19 | def printline(): 20 | try: 21 | line = raw_input() 22 | except NameError: 23 | line = input() 24 | print('%s chars.' % len(line)) 25 | 26 | gevent.spawn(printline).join() 27 | 28 | else: 29 | sys.exit('Invalid arguments: %r' % (sys.argv, )) 30 | -------------------------------------------------------------------------------- /greentest/test__joinall.py: -------------------------------------------------------------------------------- 1 | import gevent 2 | 3 | 4 | def func(): 5 | pass 6 | 7 | 8 | a = gevent.spawn(func) 9 | b = gevent.spawn(func) 10 | gevent.joinall([a, b, a]) 11 | -------------------------------------------------------------------------------- /greentest/test__local.py: -------------------------------------------------------------------------------- 1 | import greentest 2 | from copy import copy 3 | # Comment the line below to see that the standard thread.local is working correct 4 | from gevent import monkey; monkey.patch_all() 5 | 6 | 7 | from threading import local 8 | 9 | 10 | class A(local): 11 | __slots__ = ['initialized', 'obj'] 12 | 13 | path = '' 14 | 15 | def __init__(self, obj): 16 | if not hasattr(self, 'initialized'): 17 | self.obj = obj 18 | self.path = '' 19 | 20 | 21 | class Obj(object): 22 | pass 23 | 24 | 25 | class GeventLocalTestCase(greentest.TestCase): 26 | 27 | def test_copy(self): 28 | a = A(Obj()) 29 | a.path = '123' 30 | a.obj.echo = 'test' 31 | b = copy(a) 32 | """ 33 | Copy makes a shallow copy. Meaning that the attribute path 34 | has to be independent in the original and the copied object because the 35 | value is a string, but the attribute obj should be just reference to 36 | the instance of the class Obj 37 | """ 38 | self.assertEqual(a.path, b.path, 'The values in the two objects must be equal') 39 | self.assertEqual(a.obj, b.obj, 'The values must be equal') 40 | 41 | b.path = '321' 42 | self.assertNotEqual(a.path, b.path, 'The values in the two objects must be different') 43 | 44 | a.obj.echo = "works" 45 | self.assertEqual(a.obj, b.obj, 'The values must be equal') 46 | 47 | def test_objects(self): 48 | """ 49 | Test which failed in the eventlet?! 50 | """ 51 | a = A({}) 52 | a.path = '123' 53 | b = A({'one': 2}) 54 | b.path = '123' 55 | self.assertEqual(a.path, b.path, 'The values in the two objects must be equal') 56 | 57 | b.path = '321' 58 | 59 | self.assertNotEqual(a.path, b.path, 'The values in the two objects must be different') 60 | 61 | if __name__ == '__main__': 62 | greentest.main() 63 | -------------------------------------------------------------------------------- /greentest/test__loop_callback.py: -------------------------------------------------------------------------------- 1 | from gevent.core import loop 2 | 3 | count = 0 4 | 5 | 6 | def incr(): 7 | global count 8 | count += 1 9 | 10 | loop = loop() 11 | loop.run_callback(incr) 12 | loop.run() 13 | assert count == 1, count 14 | -------------------------------------------------------------------------------- /greentest/test__memleak.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | 4 | from greentest import TestCase, main 5 | import gevent 6 | from gevent.timeout import Timeout 7 | 8 | 9 | class TestQueue(TestCase): 10 | 11 | def test(self): 12 | result = '' 13 | try: 14 | Timeout.start_new(0.01) 15 | gevent.sleep(1) 16 | raise AssertionError('must raise Timeout') 17 | except KeyboardInterrupt: 18 | raise 19 | except: 20 | pass 21 | 22 | result += '%s ' % sys.gettotalrefcount() 23 | 24 | try: 25 | Timeout.start_new(0.01) 26 | gevent.sleep(1) 27 | raise AssertionError('must raise Timeout') 28 | except KeyboardInterrupt: 29 | raise 30 | except: 31 | pass 32 | 33 | result += '%s ' % sys.gettotalrefcount() 34 | 35 | try: 36 | Timeout.start_new(0.01) 37 | gevent.sleep(1) 38 | raise AssertionError('must raise Timeout') 39 | except KeyboardInterrupt: 40 | raise 41 | except: 42 | pass 43 | 44 | result += '%s' % sys.gettotalrefcount() 45 | 46 | a, b, c = result.split() 47 | assert b == c, 'total refcount mismatch: %s' % result 48 | 49 | 50 | if not hasattr(sys, 'gettotalrefcount'): 51 | del TestQueue 52 | 53 | if __name__ == '__main__': 54 | main() 55 | -------------------------------------------------------------------------------- /greentest/test__monkey.py: -------------------------------------------------------------------------------- 1 | from gevent import monkey 2 | monkey.patch_all() 3 | 4 | import time 5 | assert 'built-in' not in repr(time.sleep), repr(time.sleep) 6 | 7 | try: 8 | import thread 9 | except ImportError: 10 | import _thread as thread 11 | import threading 12 | assert 'built-in' not in repr(thread.start_new_thread), repr(thread.start_new_thread) 13 | assert 'built-in' not in repr(threading._start_new_thread), repr(threading._start_new_thread) 14 | assert 'built-in' not in repr(threading._sleep), repr(threading._sleep) 15 | 16 | import socket 17 | from gevent import socket as gevent_socket 18 | assert socket.create_connection is gevent_socket.create_connection 19 | 20 | import os 21 | if hasattr(os, 'fork'): 22 | assert 'built-in' not in repr(os.fork), repr(os.fork) 23 | 24 | assert monkey.saved 25 | -------------------------------------------------------------------------------- /greentest/test__nondefaultloop.py: -------------------------------------------------------------------------------- 1 | # test for issue #210 2 | from gevent import core 3 | from util import alarm 4 | 5 | 6 | alarm(1) 7 | 8 | log = [] 9 | loop = core.loop(default=False) 10 | loop.run_callback(log.append, 1) 11 | loop.run() 12 | assert log == [1], log 13 | -------------------------------------------------------------------------------- /greentest/test__order.py: -------------------------------------------------------------------------------- 1 | import gevent 2 | import greentest 3 | from six import xrange 4 | 5 | 6 | class appender(object): 7 | 8 | def __init__(self, lst, item): 9 | self.lst = lst 10 | self.item = item 11 | 12 | def __call__(self, *args): 13 | self.lst.append(self.item) 14 | 15 | 16 | class Test(greentest.TestCase): 17 | 18 | count = 2 19 | 20 | def test_greenlet_link(self): 21 | lst = [] 22 | 23 | # test that links are executed in the same order as they were added 24 | g = gevent.spawn(lst.append, 0) 25 | 26 | for i in xrange(1, self.count): 27 | g.link(appender(lst, i)) 28 | g.join() 29 | self.assertEqual(lst, list(range(self.count))) 30 | 31 | 32 | class Test3(Test): 33 | count = 3 34 | 35 | 36 | class Test4(Test): 37 | count = 4 38 | 39 | 40 | class TestM(Test): 41 | count = 1000 42 | 43 | 44 | class TestSleep0(greentest.TestCase): 45 | 46 | def test(self): 47 | lst = [] 48 | gevent.spawn(sleep0, lst, '1') 49 | gevent.spawn(sleep0, lst, '2') 50 | gevent.wait() 51 | self.assertEqual(' '.join(lst), '1A 2A 1B 2B') 52 | 53 | 54 | def sleep0(lst, param): 55 | lst.append(param + 'A') 56 | gevent.sleep(0) 57 | lst.append(param + 'B') 58 | 59 | 60 | if __name__ == '__main__': 61 | greentest.main() 62 | -------------------------------------------------------------------------------- /greentest/test__real_greenlet.py: -------------------------------------------------------------------------------- 1 | """Testing that greenlet restores sys.exc_info. 2 | 3 | Passes with CPython + greenlet 0.4.0 4 | 5 | Fails with PyPy 2.2.1 6 | """ 7 | from __future__ import print_function 8 | import sys 9 | import greenlet 10 | 11 | 12 | print('Your greenlet version: %s' % (getattr(greenlet, '__version__', None), )) 13 | 14 | 15 | result = [] 16 | 17 | 18 | def func(): 19 | result.append(repr(sys.exc_info())) 20 | 21 | 22 | g = greenlet.greenlet(func) 23 | try: 24 | 1 / 0 25 | except ZeroDivisionError: 26 | g.switch() 27 | 28 | 29 | assert result == ['(None, None, None)'], result 30 | -------------------------------------------------------------------------------- /greentest/test__refcount_core.py: -------------------------------------------------------------------------------- 1 | import weakref 2 | 3 | 4 | class Dummy: 5 | def __init__(self): 6 | __import__('gevent.core') 7 | 8 | 9 | assert weakref.ref(Dummy())() is None 10 | 11 | from gevent import socket 12 | 13 | assert weakref.ref(socket.socket())() is None 14 | -------------------------------------------------------------------------------- /greentest/test__select.py: -------------------------------------------------------------------------------- 1 | import six 2 | import sys 3 | import os 4 | from gevent import select, socket 5 | import greentest 6 | 7 | 8 | class TestSelect(greentest.GenericWaitTestCase): 9 | 10 | def wait(self, timeout): 11 | select.select([], [], [], timeout) 12 | 13 | 14 | if sys.platform != 'win32': 15 | 16 | class TestSelectRead(greentest.GenericWaitTestCase): 17 | 18 | def wait(self, timeout): 19 | r, w = os.pipe() 20 | try: 21 | select.select([r], [], [], timeout) 22 | finally: 23 | os.close(r) 24 | os.close(w) 25 | 26 | 27 | class TestSelectTypes(greentest.TestCase): 28 | 29 | def test_int(self): 30 | sock = socket.socket() 31 | select.select([int(sock.fileno())], [], [], 0.001) 32 | 33 | if hasattr(six.builtins, 'long'): 34 | def test_long(self): 35 | sock = socket.socket() 36 | select.select( 37 | [six.builtins.long(sock.fileno())], [], [], 0.001) 38 | 39 | def test_string(self): 40 | self.switch_expected = False 41 | self.assertRaises(TypeError, select.select, ['hello'], [], [], 0.001) 42 | 43 | 44 | if __name__ == '__main__': 45 | greentest.main() 46 | -------------------------------------------------------------------------------- /greentest/test__semaphore.py: -------------------------------------------------------------------------------- 1 | import greentest 2 | import gevent 3 | from gevent.lock import Semaphore 4 | 5 | 6 | class TestTimeoutAcquire(greentest.TestCase): 7 | 8 | # issue 39 9 | def test_acquire_returns_false_after_timeout(self): 10 | s = Semaphore(value=0) 11 | result = s.acquire(timeout=0.01) 12 | assert result is False, repr(result) 13 | 14 | def test_release_twice(self): 15 | s = Semaphore() 16 | result = [] 17 | s.rawlink(lambda s: result.append('a')) 18 | s.release() 19 | s.rawlink(lambda s: result.append('b')) 20 | s.release() 21 | gevent.sleep(0.001) 22 | self.assertEqual(result, ['a', 'b']) 23 | 24 | 25 | if __name__ == '__main__': 26 | greentest.main() 27 | -------------------------------------------------------------------------------- /greentest/test__signal.py: -------------------------------------------------------------------------------- 1 | import signal 2 | import greentest 3 | import gevent 4 | 5 | 6 | class Expected(Exception): 7 | pass 8 | 9 | 10 | def raise_Expected(): 11 | raise Expected('TestSignal') 12 | 13 | 14 | if hasattr(signal, 'SIGALRM'): 15 | 16 | class TestSignal(greentest.TestCase): 17 | 18 | error_fatal = False 19 | __timeout__ = 5 20 | 21 | def test(self): 22 | sig = gevent.signal(signal.SIGALRM, raise_Expected) 23 | assert sig.ref is False, repr(sig.ref) 24 | sig.ref = True 25 | assert sig.ref is True 26 | sig.ref = False 27 | try: 28 | signal.alarm(1) 29 | try: 30 | gevent.sleep(2) 31 | raise AssertionError('must raise Expected') 32 | except Expected as ex: 33 | assert str(ex) == 'TestSignal', ex 34 | # also let's check that alarm is persistent 35 | signal.alarm(1) 36 | try: 37 | gevent.sleep(2) 38 | raise AssertionError('must raise Expected') 39 | except Expected as ex: 40 | assert str(ex) == 'TestSignal', ex 41 | finally: 42 | sig.cancel() 43 | 44 | 45 | if __name__ == '__main__': 46 | greentest.main() 47 | -------------------------------------------------------------------------------- /greentest/test__sleep0.py: -------------------------------------------------------------------------------- 1 | import gevent 2 | from util import alarm 3 | 4 | 5 | alarm(3) 6 | 7 | 8 | with gevent.Timeout(0.01, False): 9 | while True: 10 | gevent.sleep(0) 11 | -------------------------------------------------------------------------------- /greentest/test__socket_close.py: -------------------------------------------------------------------------------- 1 | import gevent 2 | from gevent import socket 3 | from gevent import server 4 | import greentest 5 | 6 | # XXX also test: send, sendall, recvfrom, recvfrom_into, sendto 7 | 8 | 9 | def readall(socket, address): 10 | while socket.recv(1024): 11 | pass 12 | 13 | 14 | class Test(greentest.TestCase): 15 | 16 | error_fatal = False 17 | 18 | def setUp(self): 19 | self.server = server.StreamServer(('', 0), readall) 20 | self.server.start() 21 | 22 | def tearDown(self): 23 | self.server.stop() 24 | 25 | def test_recv_closed(self): 26 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 27 | sock.connect(('127.0.0.1', self.server.server_port)) 28 | receiver = gevent.spawn(sock.recv, 25) 29 | try: 30 | gevent.sleep(0.001) 31 | sock.close() 32 | receiver.join(timeout=0.1) 33 | assert receiver.ready(), receiver 34 | self.assertEqual(receiver.value, None) 35 | assert isinstance(receiver.exception, socket.error) 36 | self.assertEqual(receiver.exception.errno, socket.EBADF) 37 | finally: 38 | receiver.kill() 39 | 40 | def test_recv_twice(self): 41 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 42 | sock.connect(('127.0.0.1', self.server.server_port)) 43 | receiver = gevent.spawn(sock.recv, 25) 44 | try: 45 | gevent.sleep(0.001) 46 | self.assertRaises(AssertionError, sock.recv, 25) 47 | self.assertRaises(AssertionError, sock.recv, 25) 48 | finally: 49 | receiver.kill() 50 | 51 | 52 | if __name__ == '__main__': 53 | greentest.main() 54 | -------------------------------------------------------------------------------- /greentest/test__socket_dns6.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | import greentest 4 | import socket 5 | from test__socket_dns import TestCase, add 6 | 7 | 8 | class Test6(TestCase): 9 | 10 | # host that only has AAAA record 11 | host = 'aaaa.test-ipv6.com' 12 | 13 | def test_empty(self): 14 | self._test('getaddrinfo', self.host, 'http') 15 | 16 | def test_inet(self): 17 | self._test('getaddrinfo', self.host, None, socket.AF_INET) 18 | 19 | def test_inet6(self): 20 | self._test('getaddrinfo', self.host, None, socket.AF_INET6) 21 | 22 | def test_unspec(self): 23 | self._test('getaddrinfo', self.host, None, socket.AF_UNSPEC) 24 | 25 | 26 | class Test6_google(Test6): 27 | host = 'ipv6.google.com' 28 | 29 | 30 | class Test6_ds(Test6): 31 | # host that has both A and AAAA records 32 | host = 'ds.test-ipv6.com' 33 | 34 | 35 | add(Test6, Test6.host) 36 | add(Test6_google, Test6_google.host) 37 | add(Test6_ds, Test6_ds.host) 38 | 39 | 40 | if __name__ == '__main__': 41 | greentest.main() 42 | -------------------------------------------------------------------------------- /greentest/test__socket_errors.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2008-2009 AG Projects 2 | # Author: Denis Bilenko 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a copy 5 | # of this software and associated documentation files (the "Software"), to deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # copies of the Software, and to permit persons to whom the Software is 9 | # furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included in 12 | # all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | # THE SOFTWARE. 21 | 22 | import greentest 23 | from gevent.socket import socket, error 24 | 25 | try: 26 | from errno import WSAECONNREFUSED as ECONNREFUSED 27 | except ImportError: 28 | from errno import ECONNREFUSED 29 | 30 | 31 | class TestSocketErrors(greentest.TestCase): 32 | 33 | __timeout__ = 5 34 | 35 | def test_connection_refused(self): 36 | s = socket() 37 | try: 38 | s.connect(('127.0.0.1', 81)) 39 | except error as ex: 40 | assert ex.args[0] == ECONNREFUSED, repr(ex) 41 | assert 'refused' in str(ex).lower(), str(ex) 42 | 43 | 44 | if __name__ == '__main__': 45 | greentest.main() 46 | -------------------------------------------------------------------------------- /greentest/test__socket_ex.py: -------------------------------------------------------------------------------- 1 | import greentest 2 | from gevent import socket 3 | 4 | 5 | class TestClosedSocket(greentest.TestCase): 6 | 7 | switch_expected = False 8 | 9 | def test(self): 10 | sock = socket.socket() 11 | sock.close() 12 | try: 13 | sock.send(b'a', timeout=1) 14 | except socket.error as ex: 15 | if ex.args[0] != 9: 16 | raise 17 | 18 | 19 | class TestRef(greentest.TestCase): 20 | 21 | switch_expected = False 22 | 23 | def test(self): 24 | sock = socket.socket() 25 | assert sock.ref is True, sock.ref 26 | sock.ref = False 27 | assert sock.ref is False, sock.ref 28 | assert sock._read_event.ref is False, sock.ref 29 | assert sock._write_event.ref is False, sock.ref 30 | sock.close() 31 | 32 | 33 | if __name__ == '__main__': 34 | greentest.main() 35 | -------------------------------------------------------------------------------- /greentest/test__socket_ssl.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | from gevent import monkey; monkey.patch_all() 3 | import sys 4 | import greentest 5 | try: 6 | import httplib 7 | except ImportError: 8 | from http import client as httplib 9 | import socket 10 | 11 | if not hasattr(socket, 'ssl'): 12 | sys.exit(0) 13 | 14 | 15 | class AmazonHTTPSTests(greentest.TestCase): 16 | 17 | __timeout__ = 30 18 | 19 | def test_amazon_response(self): 20 | conn = httplib.HTTPSConnection('sdb.amazonaws.com') 21 | conn.debuglevel = 1 22 | conn.request('GET', '/') 23 | conn.getresponse() 24 | 25 | def test_str_and_repr(self): 26 | conn = socket.socket() 27 | conn.connect(('sdb.amazonaws.com', 443)) 28 | ssl_conn = socket.ssl(conn) 29 | assert str(ssl_conn) 30 | assert repr(ssl_conn) 31 | 32 | 33 | if __name__ == "__main__": 34 | greentest.main() 35 | -------------------------------------------------------------------------------- /greentest/test__socket_timeout.py: -------------------------------------------------------------------------------- 1 | import gevent 2 | from gevent import socket 3 | import greentest 4 | 5 | 6 | class Test(greentest.TestCase): 7 | 8 | def start(self): 9 | self.server = socket.socket() 10 | self.server.bind(('127.0.0.1', 0)) 11 | self.server.listen(1) 12 | self.server_port = self.server.getsockname()[1] 13 | self.acceptor = gevent.spawn(self.server.accept) 14 | 15 | def stop(self): 16 | self.server.close() 17 | self.acceptor.kill() 18 | del self.acceptor 19 | del self.server 20 | 21 | def test(self): 22 | self.start() 23 | try: 24 | sock = socket.socket() 25 | sock.connect(('127.0.0.1', self.server_port)) 26 | try: 27 | sock.settimeout(0.1) 28 | try: 29 | result = sock.recv(1024) 30 | raise AssertionError('Expected timeout to be raised, instead recv() returned %r' % (result, )) 31 | except socket.error as ex: 32 | self.assertEqual(ex.args, ('timed out',)) 33 | self.assertEqual(str(ex), 'timed out') 34 | finally: 35 | sock.close() 36 | finally: 37 | self.stop() 38 | 39 | 40 | if __name__ == '__main__': 41 | greentest.main() 42 | -------------------------------------------------------------------------------- /greentest/test__socketpair.py: -------------------------------------------------------------------------------- 1 | from gevent import monkey; monkey.patch_all() 2 | import socket 3 | import unittest 4 | 5 | 6 | class Test(unittest.TestCase): 7 | 8 | def test(self): 9 | msg = 'hello world' 10 | x, y = socket.socketpair() 11 | x.sendall(msg) 12 | x.close() 13 | read = y.makefile().read() 14 | self.assertEqual(msg, read) 15 | 16 | def test_fromfd(self): 17 | msg = 'hello world' 18 | x, y = socket.socketpair() 19 | xx = socket.fromfd(x.fileno(), x.family, socket.SOCK_STREAM) 20 | x.close() 21 | yy = socket.fromfd(y.fileno(), y.family, socket.SOCK_STREAM) 22 | y.close() 23 | 24 | xx.sendall(msg) 25 | xx.close() 26 | read = yy.makefile().read() 27 | self.assertEqual(msg, read) 28 | 29 | 30 | if __name__ == '__main__': 31 | unittest.main() 32 | -------------------------------------------------------------------------------- /greentest/test__ssl.py: -------------------------------------------------------------------------------- 1 | from gevent import monkey; monkey.patch_all() 2 | import os 3 | import socket 4 | import greentest 5 | try: 6 | from socket import sslerror 7 | except ImportError: 8 | from ssl import SSLError as sslerror 9 | from test__socket import TestTCP 10 | import ssl 11 | 12 | 13 | class TestSSL(TestTCP): 14 | 15 | certfile = os.path.join(os.path.dirname(__file__), 'test_server.crt') 16 | privfile = os.path.join(os.path.dirname(__file__), 'test_server.key') 17 | TIMEOUT_ERROR = sslerror 18 | 19 | def setUp(self): 20 | greentest.TestCase.setUp(self) 21 | self.listener, r = ssl_listener(('127.0.0.1', 0), self.privfile, self.certfile) 22 | self.port = self.listener.getsockname()[1] 23 | 24 | def create_connection(self): 25 | return ssl.wrap_socket(super(TestSSL, self).create_connection()) 26 | 27 | def test_sendall_timeout(self): 28 | pass 29 | 30 | del TestTCP 31 | 32 | 33 | def ssl_listener(address, private_key, certificate): 34 | r = socket.socket() 35 | greentest.bind_and_listen(r, address) 36 | sock = ssl.wrap_socket(r, private_key, certificate) 37 | return sock, r 38 | 39 | 40 | if __name__ == '__main__': 41 | greentest.main() 42 | -------------------------------------------------------------------------------- /greentest/test__subprocess_interrupted.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from six import xrange 3 | 4 | 5 | if 'runtestcase' in sys.argv[1:]: 6 | import gevent 7 | import gevent.subprocess 8 | gevent.spawn(sys.exit, 'bye') 9 | gevent.subprocess.Popen('python -c "1/0"'.split()) 10 | gevent.sleep(1) 11 | else: 12 | import subprocess 13 | for _ in xrange(5): 14 | out, err = subprocess.Popen([sys.executable, __file__, 'runtestcase'], stderr=subprocess.PIPE).communicate() 15 | if b'refs' in err: 16 | assert err.startswith(b'bye'), repr(err) 17 | else: 18 | assert err.strip() == b'bye', repr(err) 19 | -------------------------------------------------------------------------------- /greentest/test__subprocess_poll.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from gevent.subprocess import Popen 3 | from util import alarm 4 | 5 | alarm(3) 6 | 7 | popen = Popen([sys.executable, '-c', 'pass']) 8 | while popen.poll() is None: 9 | pass 10 | -------------------------------------------------------------------------------- /greentest/test__systemerror.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import greentest 3 | import gevent 4 | from gevent.hub import get_hub 5 | 6 | 7 | def raise_(ex): 8 | raise ex 9 | 10 | 11 | MSG = 'should be re-raised and caught' 12 | 13 | 14 | class Test(greentest.TestCase): 15 | 16 | error_fatal = False 17 | 18 | def test_sys_exit(self): 19 | self.start(sys.exit, MSG) 20 | 21 | try: 22 | gevent.sleep(0.001) 23 | except SystemExit as ex: 24 | assert str(ex) == MSG, repr(str(ex)) 25 | else: 26 | raise AssertionError('must raise SystemExit') 27 | 28 | def test_keyboard_interrupt(self): 29 | self.start(raise_, KeyboardInterrupt) 30 | 31 | try: 32 | gevent.sleep(0.001) 33 | except KeyboardInterrupt: 34 | pass 35 | else: 36 | raise AssertionError('must raise KeyboardInterrupt') 37 | 38 | def test_system_error(self): 39 | self.start(raise_, SystemError(MSG)) 40 | 41 | try: 42 | gevent.sleep(0.001) 43 | except SystemError as ex: 44 | assert str(ex) == MSG, repr(str(ex)) 45 | else: 46 | raise AssertionError('must raise SystemError') 47 | 48 | def test_exception(self): 49 | self.start(raise_, Exception('regular exception must not kill the program')) 50 | gevent.sleep(0.001) 51 | 52 | 53 | class TestCallback(Test): 54 | 55 | def tearDown(self): 56 | assert not self.x.pending, self.x 57 | 58 | def start(self, *args): 59 | self.x = get_hub().loop.run_callback(*args) 60 | 61 | 62 | class TestSpawn(Test): 63 | 64 | def tearDown(self): 65 | gevent.sleep(0.0001) 66 | assert self.x.dead, self.x 67 | 68 | def start(self, *args): 69 | self.x = gevent.spawn(*args) 70 | 71 | 72 | del Test 73 | 74 | if __name__ == '__main__': 75 | greentest.main() 76 | -------------------------------------------------------------------------------- /greentest/test__threading.py: -------------------------------------------------------------------------------- 1 | from gevent import monkey; monkey.patch_all() 2 | import gevent.hub 3 | 4 | # check that the locks initialized by 'threading' did not init the hub 5 | assert gevent.hub._get_hub() is None, 'monkey.patch_all() should not init hub' 6 | 7 | import gevent 8 | import greentest 9 | import threading 10 | 11 | 12 | def helper(): 13 | threading.currentThread() 14 | gevent.sleep(0.2) 15 | 16 | 17 | class Test(greentest.TestCase): 18 | 19 | def test(self): 20 | before = len(threading._active) 21 | g = gevent.spawn(helper) 22 | gevent.sleep(0.1) 23 | self.assertEqual(len(threading._active), before + 1) 24 | g.join() 25 | self.assertEqual(len(threading._active), before) 26 | 27 | 28 | if __name__ == '__main__': 29 | greentest.main() 30 | -------------------------------------------------------------------------------- /greentest/test__threading_patched_local.py: -------------------------------------------------------------------------------- 1 | from gevent import monkey; monkey.patch_all() 2 | import threading 3 | 4 | localdata = threading.local() 5 | localdata.x = "hello" 6 | assert localdata.x == 'hello' 7 | success = [] 8 | 9 | 10 | def func(): 11 | try: 12 | localdata.x 13 | raise AssertionError('localdata.x must raise AttributeError') 14 | except AttributeError: 15 | pass 16 | assert localdata.__dict__ == {}, localdata.__dict__ 17 | success.append(1) 18 | 19 | t = threading.Thread(None, func) 20 | t.start() 21 | t.join() 22 | assert success == [1], 'test failed' 23 | assert localdata.x == 'hello' 24 | -------------------------------------------------------------------------------- /greentest/test_ares_timeout.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | import sys 3 | import gevent 4 | try: 5 | from gevent.resolver_ares import Resolver 6 | except ImportError as ex: 7 | print(ex) 8 | sys.exit(0) 9 | from gevent import socket 10 | print(gevent.__file__) 11 | 12 | address = ('127.0.0.10', 53) 13 | listener = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 14 | try: 15 | listener.bind(address) 16 | except socket.error as ex: 17 | if 'permission denied' in str(ex).lower(): 18 | sys.stderr.write('This test binds on port 53 and thus must be run as root.\n') 19 | sys.exit(0) 20 | raise 21 | 22 | 23 | def reader(): 24 | while True: 25 | print(listener.recvfrom(10000)) 26 | 27 | gevent.spawn(reader) 28 | 29 | r = gevent.get_hub().resolver = Resolver(servers=[b'127.0.0.10'], timeout=0.001, tries=1) 30 | try: 31 | result = r.gethostbyname('www.google.com') 32 | except socket.gaierror as ex: 33 | if 'ARES_ETIMEOUT' not in str(ex): 34 | raise 35 | else: 36 | raise AssertionError('Expected timeout, got %r' % (result, )) 37 | -------------------------------------------------------------------------------- /greentest/test_close_backend_fd.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | import os 3 | import gevent 4 | from gevent import core 5 | from six import xrange 6 | 7 | 8 | for count in xrange(2): 9 | for backend in core.supported_backends(): 10 | hub = gevent.get_hub(backend, default=False) 11 | assert hub.loop.backend == backend, (hub.loop.backend, backend) 12 | gevent.sleep(0.001) 13 | fileno = hub.loop.fileno() 14 | if fileno is not None: 15 | print('%s. Testing %r: %r' % (count, backend, hub)) 16 | os.close(fileno) 17 | try: 18 | gevent.sleep(0.001) 19 | except SystemError as ex: 20 | if '(libev)' in str(ex): 21 | print('The error is expected: %s' % ex) 22 | else: 23 | raise 24 | else: 25 | raise AssertionError('gevent.sleep() is expected to fail after loop fd was closed') 26 | else: 27 | print('%s. %r lacks fileno()' % (count, backend)) 28 | hub.destroy() 29 | assert 'destroyed' in repr(hub), repr(hub) 30 | -------------------------------------------------------------------------------- /greentest/test_hub_join.py: -------------------------------------------------------------------------------- 1 | import gevent 2 | 3 | # hub.join() guarantees that loop has exited cleanly 4 | res = gevent.get_hub().join() 5 | assert res is True, res 6 | res = gevent.get_hub().join() 7 | assert res is True, res 8 | 9 | # but it is still possible to use gevent afterwards 10 | gevent.sleep(0.01) 11 | 12 | res = gevent.get_hub().join() 13 | assert res is True, res 14 | -------------------------------------------------------------------------------- /greentest/test_issue112.py: -------------------------------------------------------------------------------- 1 | import threading 2 | import gevent.monkey 3 | gevent.monkey.patch_all() 4 | import gevent 5 | 6 | assert threading._sleep is gevent.sleep, threading._sleep 7 | -------------------------------------------------------------------------------- /greentest/test_server.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICYzCCAcwCCQD5jx1Aa0dytjANBgkqhkiG9w0BAQQFADB2MQswCQYDVQQGEwJU 3 | UzENMAsGA1UECBMEVGVzdDENMAsGA1UEBxMEVGVzdDEWMBQGA1UEChMNVGVzdCBF 4 | dmVudGxldDENMAsGA1UECxMEVGVzdDENMAsGA1UEAxMEVGVzdDETMBEGCSqGSIb3 5 | DQEJARYEVGVzdDAeFw0wODA3MDgyMTExNDJaFw0xMDAyMDgwODE1MTBaMHYxCzAJ 6 | BgNVBAYTAlRTMQ0wCwYDVQQIEwRUZXN0MQ0wCwYDVQQHEwRUZXN0MRYwFAYDVQQK 7 | Ew1UZXN0IEV2ZW50bGV0MQ0wCwYDVQQLEwRUZXN0MQ0wCwYDVQQDEwRUZXN0MRMw 8 | EQYJKoZIhvcNAQkBFgRUZXN0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDM 9 | WcyeIiHQuEGQxgTIvu0aOW4iRFAyUEi8pLWNCxMEHglF8k6OxFVq7XWZMDnDFVnb 10 | ZjmQh5Tc21Ae6cXzxXln578fROXHEzXo3Is8HUlq3ug1yYOGHjxw++Opjf1uoHwP 11 | EBUKsz/flS7knuscgFM9FO05KSPn2wHnZeIDta4yTwIDAQABMA0GCSqGSIb3DQEB 12 | BAUAA4GBAKM71aP0r26gEEEBzovfXm1IwKav6R9/xiWsJ4pFsUXVotcaIjcVBDG1 13 | Z7tz688hokb+GNxsTI2gNfqanqUnfP9wZxnKRmfTSOvb5aWHIiaiMXSgjiPlqBcm 14 | 6mnSeEbSMM9cw479wWhh1YqY8tf3gYJa+sxznVWLSfVLpsjRMphe 15 | -----END CERTIFICATE----- 16 | -------------------------------------------------------------------------------- /greentest/test_server.key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXgIBAAKBgQDMWcyeIiHQuEGQxgTIvu0aOW4iRFAyUEi8pLWNCxMEHglF8k6O 3 | xFVq7XWZMDnDFVnbZjmQh5Tc21Ae6cXzxXln578fROXHEzXo3Is8HUlq3ug1yYOG 4 | Hjxw++Opjf1uoHwPEBUKsz/flS7knuscgFM9FO05KSPn2wHnZeIDta4yTwIDAQAB 5 | AoGBAKWfvq0IIvok7Ncm92ew/0D6/R1+2rT8xwdGQ/Nt31q98WwkqLEjxctlbKPd 6 | J2PLIUomf0955BhhFH4JoSwjiHJQ6uishY7srjQQDX/Dxdi5wZAyxYCIVW/kAA9N 7 | /u2s75hSD3s/rqAwOZ182DwAPIqJc4KQoYzvlKERSMDT1PJhAkEA5SUFsiSzBEMX 8 | FyZ++ZMMs1vHrTu5oTK7WHznh9lk7dvsnp9BoUPqhiu8iJ7Q23zj0u5asz2czu11 9 | nnczXgU6XwJBAORM5Ib4I7nAsoUWn9wDiTwVQeE+D9P1ac9p7EHm7XXuf8o2irRZ 10 | wYYfpXXsjk496YfyQFcQRMk0tU0gegCP7hECQFWRWqwoajUoPIInnPjjwbVki48U 11 | I4CfqjgkBG3Fb5wnKRgezmpDK1vJD1FRRRsBay4EVhhi5KCdKfPv/V2ZxC8CQQCu 12 | U5SxBytofJ8UhxkcTErvaR/8GYLGi//21GAGVop+YdaMlydE3cCrZODYcgCb+CSp 13 | nS7KDG8p4KiMMz9VzJGxAkEAv85K6Sa3H8g9h7LwopBZ5tFNZUaFWo7lEP7DDMH0 14 | eckZTb1JVpyT/8zrDtsis4WlV9zVkVHxkIaad503BjqvEQ== 15 | -----END RSA PRIVATE KEY----- 16 | -------------------------------------------------------------------------------- /greentest/wrongcert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXAIBAAKBgQC89ZNxjTgWgq7Z1g0tJ65w+k7lNAj5IgjLb155UkUrz0XsHDnH 3 | FlbsVUg2Xtk6+bo2UEYIzN7cIm5ImpmyW/2z0J1IDVDlvR2xJ659xrE0v5c2cB6T 4 | f9lnNTwpSoeK24Nd7Jwq4j9vk95fLrdqsBq0/KVlsCXeixS/CaqqduXfvwIDAQAB 5 | AoGAQFko4uyCgzfxr4Ezb4Mp5pN3Npqny5+Jey3r8EjSAX9Ogn+CNYgoBcdtFgbq 6 | 1yif/0sK7ohGBJU9FUCAwrqNBI9ZHB6rcy7dx+gULOmRBGckln1o5S1+smVdmOsW 7 | 7zUVLBVByKuNWqTYFlzfVd6s4iiXtAE2iHn3GCyYdlICwrECQQDhMQVxHd3EFbzg 8 | SFmJBTARlZ2GKA3c1g/h9/XbkEPQ9/RwI3vnjJ2RaSnjlfoLl8TOcf0uOGbOEyFe 9 | 19RvCLXjAkEA1s+UE5ziF+YVkW3WolDCQ2kQ5WG9+ccfNebfh6b67B7Ln5iG0Sbg 10 | ky9cjsO3jbMJQtlzAQnH1850oRD5Gi51dQJAIbHCDLDZU9Ok1TI+I2BhVuA6F666 11 | lEZ7TeZaJSYq34OaUYUdrwG9OdqwZ9sy9LUav4ESzu2lhEQchCJrKMn23QJAReqs 12 | ZLHUeTjfXkVk7dHhWPWSlUZ6AhmIlA/AQ7Payg2/8wM/JkZEJEPvGVykms9iPUrv 13 | frADRr+hAGe43IewnQJBAJWKZllPgKuEBPwoEldHNS8nRu61D7HzxEzQ2xnfj+Nk 14 | 2fgf1MAzzTRsikfGENhVsVWeqOcijWb6g5gsyCmlRpc= 15 | -----END RSA PRIVATE KEY----- 16 | -----BEGIN CERTIFICATE----- 17 | MIICsDCCAhmgAwIBAgIJAOqYOYFJfEEoMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV 18 | BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX 19 | aWRnaXRzIFB0eSBMdGQwHhcNMDgwNjI2MTgxNTUyWhcNMDkwNjI2MTgxNTUyWjBF 20 | MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50 21 | ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB 22 | gQC89ZNxjTgWgq7Z1g0tJ65w+k7lNAj5IgjLb155UkUrz0XsHDnHFlbsVUg2Xtk6 23 | +bo2UEYIzN7cIm5ImpmyW/2z0J1IDVDlvR2xJ659xrE0v5c2cB6Tf9lnNTwpSoeK 24 | 24Nd7Jwq4j9vk95fLrdqsBq0/KVlsCXeixS/CaqqduXfvwIDAQABo4GnMIGkMB0G 25 | A1UdDgQWBBTctMtI3EO9OjLI0x9Zo2ifkwIiNjB1BgNVHSMEbjBsgBTctMtI3EO9 26 | OjLI0x9Zo2ifkwIiNqFJpEcwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUt 27 | U3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJAOqYOYFJ 28 | fEEoMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAQwa7jya/DfhaDn7E 29 | usPkpgIX8WCL2B1SqnRTXEZfBPPVq/cUmFGyEVRVATySRuMwi8PXbVcOhXXuocA+ 30 | 43W+iIsD9pXapCZhhOerCq18TC1dWK98vLUsoK8PMjB6e5H/O8bqojv0EeC+fyCw 31 | eSHj5jpC8iZKjCHBn+mAi4cQ514= 32 | -----END CERTIFICATE----- 33 | -------------------------------------------------------------------------------- /greentest/xtest__benchmarks.py: -------------------------------------------------------------------------------- 1 | # testrunner timeout: 300 2 | import sys 3 | import glob 4 | import subprocess 5 | import time 6 | 7 | 8 | TIMEOUT = 30 9 | 10 | 11 | def kill(popen): 12 | if popen.poll() is not None: 13 | return 14 | try: 15 | popen.kill() 16 | except OSError as ex: 17 | if ex.errno == 3: # No such process 18 | return 19 | if ex.errno == 13: # Permission denied (translated from windows error 5: "Access is denied") 20 | return 21 | raise 22 | 23 | 24 | def wait(popen): 25 | end = time.time() + TIMEOUT 26 | while popen.poll() is None: 27 | if time.time() > end: 28 | kill(popen) 29 | popen.wait() 30 | return 'TIMEOUT' 31 | time.sleep(0.1) 32 | return popen.poll() 33 | 34 | 35 | def system(command): 36 | popen = subprocess.Popen(command, shell=False) 37 | try: 38 | return wait(popen) 39 | finally: 40 | kill(popen) 41 | 42 | 43 | modules = set() 44 | 45 | for path in glob.glob('bench_*.py'): 46 | modules.add(path) 47 | 48 | if __name__ == '__main__': 49 | assert modules 50 | 51 | errors = [] 52 | 53 | for path in modules: 54 | sys.stderr.write(path + '\n') 55 | sys.stdout.flush() 56 | command = [sys.executable, '-u', path, 'all'] 57 | res = system(command) 58 | if res: 59 | error = '%r failed with %s' % (' '.join(command), res) 60 | sys.stderr.write(error + '\n') 61 | errors.append(error) 62 | sys.stderr.write('-----\n\n') 63 | 64 | if errors: 65 | sys.exit('\n'.join(errors)) 66 | -------------------------------------------------------------------------------- /greentest/xtest__issue91.py: -------------------------------------------------------------------------------- 1 | from gevent.select import select 2 | from gevent.server import StreamServer 3 | from gevent import socket 4 | 5 | 6 | def handler(socket, address): 7 | while True: 8 | if not socket.recv(1000): 9 | break 10 | 11 | 12 | server = StreamServer(('127.0.0.1', 0), handler) 13 | server.start() 14 | 15 | s = socket.create_connection(('127.0.0.1', server.server_port)) 16 | while True: 17 | select([], [s.fileno()] * 10, []) 18 | -------------------------------------------------------------------------------- /greentest/xtest_stdlib.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | 4 | if os.system("ack 'from test import (?!test_support)|from test\.(?!test_support)' 2.5 2.6 2.7") != 256: 5 | sys.exit('FAILED: Some tests in stdlib were not updated to not reference "test".') 6 | -------------------------------------------------------------------------------- /util/makedeb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | CWD=`pwd` 4 | rm -fr /tmp/build_gevent_deb 5 | set -x 6 | mkdir /tmp/build_gevent_deb 7 | #util/makedist.py --dest /tmp/build_gevent_deb/gevent.tar.gz --version dev 8 | cd /tmp/build_gevent_deb 9 | tar -xf $CWD/dist/gevent-1.0.tar.gz 10 | fpm --no-python-dependencies -s python -t deb gevent*/setup.py 11 | mkdir -p $CWD/build 12 | mv *.deb $CWD/build/ 13 | --------------------------------------------------------------------------------