repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
gevent | gevent-master/src/gevent/_imap.py | # -*- coding: utf-8 -*-
# Copyright (c) 2018 gevent
# cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False,infer_types=True
"""
Iterators across greenlets or AsyncResult objects.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
fro... | 7,672 | 32.801762 | 99 | py |
gevent | gevent-master/src/gevent/_tracer.py | # Copyright (c) 2018 gevent. See LICENSE for details.
# cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False
from __future__ import print_function, absolute_import, division
import sys
import traceback
from greenlet import settrace
from greenlet import getcurrent
from gevent.util import format_r... | 6,455 | 34.278689 | 85 | py |
gevent | gevent-master/src/gevent/local.py | # cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False
"""
Greenlet-local objects.
This module is based on `_threading_local.py`__ from the standard
library of Python 3.4.
__ https://github.com/python/cpython/blob/3.4/Lib/_threading_local.py
Greenlet-local objects support the management of green... | 21,457 | 34.119476 | 100 | py |
gevent | gevent-master/src/gevent/resolver_ares.py | """Backwards compatibility alias for :mod:`gevent.resolver.ares`.
.. deprecated:: 1.3
Use :mod:`gevent.resolver.ares`
"""
import warnings
warnings.warn(
"gevent.resolver_ares is deprecated and will be removed in 1.5. "
"Use gevent.resolver.ares instead.",
DeprecationWarning,
stacklevel=2
)
del warni... | 486 | 26.055556 | 90 | py |
gevent | gevent-master/src/gevent/_compat.py | # -*- coding: utf-8 -*-
"""
internal gevent python 2/python 3 bridges. Not for external use.
"""
from __future__ import print_function, absolute_import, division
## Important: This module should generally not have any other gevent
## imports (the exception is _util_py2)
import sys
import os
PY39 = sys.version_info... | 2,726 | 24.25 | 80 | py |
gevent | gevent-master/src/gevent/_config.py | # Copyright (c) 2018 gevent. See LICENSE for details.
"""
gevent tunables.
This should be used as ``from gevent import config``. That variable
is an object of :class:`Config`.
.. versionadded:: 1.3a2
.. versionchanged:: 22.08.0
Invoking this module like ``python -m gevent._config`` will
print a help message ab... | 21,428 | 28.075984 | 97 | py |
gevent | gevent-master/src/gevent/pywsgi.py | # Copyright (c) 2005-2009, eventlet contributors
# Copyright (c) 2009-2018, gevent contributors
"""
A pure-Python, gevent-friendly WSGI server.
The server is provided in :class:`WSGIServer`, but most of the actual
WSGI work is handled by :class:`WSGIHandler` --- a new instance is
created for each request. The server c... | 63,155 | 38.720755 | 135 | py |
gevent | gevent-master/src/gevent/_hub_primitives.py | # -*- coding: utf-8 -*-
# copyright (c) 2018 gevent. See LICENSE.
# cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False,binding=True
"""
A collection of primitives used by the hub, and suitable for
compilation with Cython because of their frequency of use.
"""
from __future__ import absolute_im... | 14,026 | 31.773364 | 96 | py |
gevent | gevent-master/src/gevent/_util.py | # -*- coding: utf-8 -*-
"""
internal gevent utilities, not for external use.
"""
# Be very careful not to import anything that would cause issues with
# monkey-patching.
from __future__ import print_function, absolute_import, division
from gevent._compat import iteritems
class _NONE(object):
"""
A special ... | 10,964 | 30.150568 | 83 | py |
gevent | gevent-master/src/gevent/select.py | # Copyright (c) 2009-2011 Denis Bilenko. See LICENSE for details.
"""
Waiting for I/O completion.
"""
from __future__ import absolute_import, division, print_function
import sys
import select as __select__
from gevent.event import Event
from gevent.hub import _get_hub_noargs as get_hub
from gevent.hub import sleep as... | 12,840 | 34.084699 | 100 | py |
gevent | gevent-master/src/gevent/builtins.py | # Copyright (c) 2015 gevent contributors. See LICENSE for details.
"""gevent friendly implementations of builtin functions."""
from __future__ import absolute_import
import weakref
from gevent.lock import RLock
from gevent._compat import imp_acquire_lock
from gevent._compat import imp_release_lock
import builtins ... | 4,108 | 32.406504 | 86 | py |
gevent | gevent-master/src/gevent/_socketcommon.py | # Copyright (c) 2009-2014 Denis Bilenko and gevent contributors. See LICENSE for details.
from __future__ import absolute_import
# standard functions and classes that this module re-implements in a gevent-aware way:
_implements = [
'create_connection',
'socket',
'SocketType',
'fromfd',
'socketpair'... | 26,199 | 33.519104 | 105 | py |
gevent | gevent-master/src/gevent/contextvars.py | # -*- coding: utf-8 -*-
"""
Cooperative ``contextvars`` module.
This module was added to Python 3.7. The gevent version is available
on all supported versions of Python. However, see an important note
about gevent 20.9.
Context variables are like greenlet-local variables, just more
inconvenient to use. They were desi... | 9,838 | 27.191977 | 86 | py |
gevent | gevent-master/src/gevent/queue.py | # Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details.
# copyright (c) 2018 gevent
# cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False
"""
Synchronized queues.
The :mod:`gevent.queue` module implements multi-producer, multi-consumer queues
that work across greenlets, with the API sim... | 23,377 | 32.444921 | 117 | py |
gevent | gevent-master/src/gevent/server.py | # Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details.
"""TCP/SSL server"""
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
import sys
from _socket import error as SocketError
from _socket import SOL_SOCKET
from _socket import SO_REUSEADDR
from _... | 10,852 | 36.295533 | 96 | py |
gevent | gevent-master/src/gevent/hub.py | # Copyright (c) 2009-2015 Denis Bilenko. See LICENSE for details.
"""
Event-loop hub.
"""
from __future__ import absolute_import, print_function
# XXX: FIXME: Refactor to make this smaller
# pylint:disable=too-many-lines
from functools import partial as _functools_partial
import sys
import traceback
from greenlet im... | 34,590 | 37.012088 | 103 | py |
gevent | gevent-master/src/gevent/_hub_local.py | # -*- coding: utf-8 -*-
# copyright 2018 gevent. See LICENSE
"""
Maintains the thread local hub.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import _thread
__all__ = [
'get_hub',
'get_hub_noargs',
'get_hub_if_exists',
]
# These must b... | 4,763 | 30.549669 | 91 | py |
gevent | gevent-master/src/gevent/timeout.py | # Copyright (c) 2009-2010 Denis Bilenko. See LICENSE for details.
"""
Timeouts.
Many functions in :mod:`gevent` have a *timeout* argument that allows
limiting the time the function will block. When that is not available,
the :class:`Timeout` class and :func:`with_timeout` function in this
module add timeouts to arbitr... | 12,940 | 32.788512 | 105 | py |
gevent | gevent-master/src/gevent/lock.py | # Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details.
"""
Locking primitives.
These include semaphores with arbitrary bounds (:class:`Semaphore` and
its safer subclass :class:`BoundedSemaphore`) and a semaphore with
infinite bounds (:class:`DummySemaphore`), along with a reentrant lock
(:class:`RLock`) wit... | 11,398 | 29.560322 | 100 | py |
gevent | gevent-master/src/gevent/subprocess.py | """
Cooperative ``subprocess`` module.
.. caution:: On POSIX platforms, this module is not usable from native
threads other than the main thread; attempting to do so will raise
a :exc:`TypeError`. This module depends on libev's fork watchers.
On POSIX systems, fork watchers are implemented using signals, and
... | 81,632 | 39.694417 | 128 | py |
gevent | gevent-master/src/gevent/signal.py | """
Cooperative implementation of special cases of :func:`signal.signal`.
This module is designed to work with libev's child watchers, as used
by default in :func:`gevent.os.fork` Note that each ``SIGCHLD``
handler will be run in a new greenlet when the signal is delivered
(just like :class:`gevent.hub.signal`)
The i... | 5,190 | 35.300699 | 102 | py |
gevent | gevent-master/src/gevent/threadpool.py | # Copyright (c) 2012 Denis Bilenko. See LICENSE for details.
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os
import sys
from greenlet import greenlet as RawGreenlet
from gevent import monkey
from gevent._compat import integer_types
from gevent.e... | 30,975 | 36.77561 | 111 | py |
gevent | gevent-master/src/gevent/event.py | # Copyright (c) 2009-2016 Denis Bilenko, gevent contributors. See LICENSE for details.
# cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False,infer_types=True
"""Basic synchronization primitives: Event and AsyncResult"""
from __future__ import print_function
from gevent._util import _NONE
from ge... | 15,037 | 34.217799 | 111 | py |
gevent | gevent-master/src/gevent/greenlet.py | # Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details.
# cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False
# pylint:disable=too-many-lines
from __future__ import absolute_import, print_function, division
from sys import _getframe as sys_getframe
from sys import exc_info as sys_exc_in... | 45,582 | 37.14477 | 115 | py |
gevent | gevent-master/src/gevent/fileobject.py | """
Wrappers to make file-like objects cooperative.
.. class:: FileObject(fobj, mode='r', buffering=-1, closefd=True, encoding=None, errors=None, newline=None)
The main entry point to the file-like gevent-compatible behaviour. It
will be defined to be the best available implementation.
All the parameters... | 3,020 | 34.127907 | 107 | py |
gevent | gevent-master/src/gevent/_patcher.py | # Copyright 2018 gevent. See LICENSE for details.
# Portions of the following are inspired by code from eventlet. I
# believe they are distinct enough that no eventlet copyright would
# apply (they are not a copy or substantial portion of the eventlot
# code).
# Added in gevent 1.3a2. Not public in that release.
fro... | 9,020 | 34.656126 | 92 | py |
gevent | gevent-master/src/gevent/_fileobjectcommon.py | """
gevent internals.
"""
from __future__ import absolute_import, print_function, division
try:
from errno import EBADF
except ImportError:
EBADF = 9
import io
import functools
import sys
import os
from gevent.hub import _get_hub_noargs as get_hub
from gevent._compat import integer_types
from gevent._compat ... | 24,295 | 33.857963 | 96 | py |
gevent | gevent-master/src/gevent/time.py | # Copyright (c) 2018 gevent. See LICENSE for details.
"""
The standard library :mod:`time` module, but :func:`sleep` is
gevent-aware.
.. versionadded:: 1.3a2
"""
from __future__ import absolute_import
__implements__ = [
'sleep',
]
__all__ = __implements__
import time as __time__
from gevent._util import copy_... | 491 | 16.571429 | 61 | py |
gevent | gevent-master/src/gevent/selectors.py | # Copyright (c) 2020 gevent contributors.
"""
This module provides :class:`GeventSelector`, a high-level IO
multiplexing mechanism. This is aliased to :class:`DefaultSelector`.
This module provides the same API as the selectors defined in :mod:`selectors`.
On Python 2, this module is only available if the `selectors2... | 11,450 | 36.178571 | 95 | py |
gevent | gevent-master/src/gevent/_abstract_linkable.py | # -*- coding: utf-8 -*-
# cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False
"""
Internal module, support for the linkable protocol for "event" like objects.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import sys
from gc impor... | 22,722 | 40.541133 | 102 | py |
gevent | gevent-master/src/gevent/_monitor.py | # Copyright (c) 2018 gevent. See LICENSE for details.
from __future__ import print_function, absolute_import, division
import os
import sys
from weakref import ref as wref
from greenlet import getcurrent
from gevent import config as GEVENT_CONFIG
from gevent.monkey import get_original
from gevent.events import noti... | 11,391 | 35.165079 | 91 | py |
gevent | gevent-master/src/gevent/util.py | # Copyright (c) 2009 Denis Bilenko. See LICENSE for details.
"""
Low-level utilities.
"""
from __future__ import absolute_import, print_function, division
import functools
import pprint
import sys
import traceback
from greenlet import getcurrent
from gevent._compat import perf_counter
from gevent._compat import PYP... | 23,756 | 33.430435 | 100 | py |
gevent | gevent-master/src/gevent/thread.py | """
Implementation of the standard :mod:`thread` module that spawns greenlets.
.. note::
This module is a helper for :mod:`gevent.monkey` and is not
intended to be used directly. For spawning greenlets in your
applications, prefer higher level constructs like
:class:`gevent.Greenlet` class or :func:`g... | 5,362 | 30.922619 | 99 | py |
gevent | gevent-master/src/gevent/_waiter.py | # -*- coding: utf-8 -*-
# copyright 2018 gevent
# cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False
"""
Low-level waiting primitives.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import sys
from gevent._hub_local import get_h... | 7,387 | 34.519231 | 112 | py |
gevent | gevent-master/src/gevent/_ident.py | # -*- coding: utf-8 -*-
# Copyright 2018 gevent contributors. See LICENSE for details.
# cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from weakref import WeakKeyDictionary
from we... | 2,249 | 26.108434 | 93 | py |
gevent | gevent-master/src/gevent/ares.py | """Backwards compatibility alias for :mod:`gevent.resolver.cares`.
.. deprecated:: 1.3
Use :mod:`gevent.resolver.cares`
"""
# pylint:disable=no-name-in-module,import-error
from gevent.resolver.cares import * # pylint:disable=wildcard-import,unused-wildcard-import,
import gevent.resolver.cares as _cares
__all__ = _c... | 383 | 33.909091 | 92 | py |
gevent | gevent-master/src/gevent/__init__.py | # Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details.
"""
gevent is a coroutine-based Python networking library that uses greenlet
to provide a high-level synchronous API on top of libev event loop.
See http://www.gevent.org/ for the documentation.
.. versionchanged:: 1.3a2
Add the `config` object.
"""... | 3,411 | 28.669565 | 94 | py |
gevent | gevent-master/src/gevent/_fileobjectposix.py | from __future__ import absolute_import
from __future__ import print_function
import os
import sys
from io import BytesIO
from io import DEFAULT_BUFFER_SIZE
from io import FileIO
from io import RawIOBase
from io import UnsupportedOperation
from gevent._compat import reraise
from gevent._fileobjectcommon import cancel... | 12,840 | 36.328488 | 88 | py |
gevent | gevent-master/src/gevent/ssl.py | # Wrapper module for _ssl. Written by Bill Janssen.
# Ported to gevent by Denis Bilenko.
"""SSL wrapper for socket objects on Python 3.
For the documentation, refer to :mod:`ssl` module manual.
This module implements cooperative SSL socket wrappers.
"""
from __future__ import absolute_import
import ssl as __ssl__
_... | 31,099 | 37.395062 | 116 | py |
gevent | gevent-master/src/gevent/socket.py | # Copyright (c) 2009-2014 Denis Bilenko and gevent contributors. See LICENSE for details.
"""Cooperative low-level networking interface.
This module provides socket operations and some related functions.
The API of the functions and classes matches the API of the corresponding
items in the standard :mod:`socket` modu... | 6,298 | 37.408537 | 102 | py |
gevent | gevent-master/src/gevent/os.py | """
Low-level operating system functions from :mod:`os`.
Cooperative I/O
===============
This module provides cooperative versions of :func:`os.read` and
:func:`os.write`. These functions are *not* monkey-patched; you
must explicitly call them or monkey patch them yourself.
POSIX functions
---------------
On POSIX,... | 20,604 | 37.2282 | 102 | py |
gevent | gevent-master/src/gevent/pool.py | # Copyright (c) 2009-2011 Denis Bilenko. See LICENSE for details.
"""
Managing greenlets in a group.
The :class:`Group` class in this module abstracts a group of running
greenlets. When a greenlet dies, it's automatically removed from the
group. All running greenlets in a group can be waited on with
:meth:`Group.join`... | 25,634 | 36.809735 | 107 | py |
gevent | gevent-master/src/gevent/resolver_thread.py | """Backwards compatibility alias for :mod:`gevent.resolver.thread`.
.. deprecated:: 1.3
Use :mod:`gevent.resolver.thread`
"""
import warnings
warnings.warn(
"gevent.resolver_thread is deprecated and will be removed in 1.5. "
"Use gevent.resolver.thread instead.",
DeprecationWarning,
stacklevel=2
)
d... | 504 | 27.055556 | 92 | py |
gevent | gevent-master/src/gevent/monkey.py | # Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details.
# pylint: disable=redefined-outer-name,too-many-lines
"""
Make the standard library cooperative.
The primary purpose of this module is to carefully patch, in place,
portions of the standard library with gevent-friendly functions that
behave in the same ... | 52,048 | 37.299485 | 129 | py |
gevent | gevent-master/src/gevent/baseserver.py | """Base class for implementing servers"""
# Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details.
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
import sys
import _socket
import errno
from gevent.greenlet import Greenlet
from gevent.event import ... | 16,614 | 36.675737 | 111 | py |
gevent | gevent-master/src/gevent/testing/openfiles.py | # Copyright (c) 2018 gevent community
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, di... | 8,739 | 37.333333 | 139 | py |
gevent | gevent-master/src/gevent/testing/travis.py | # -*- coding: utf-8 -*-
# Support functions for travis
# See https://github.com/travis-ci/travis-rubies/blob/9f7962a881c55d32da7c76baefc58b89e3941d91/build.sh
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import sys
commands = {}
def command(func):
... | 877 | 19.904762 | 103 | py |
gevent | gevent-master/src/gevent/testing/monkey_test.py | import sys
import os
test_filename = sys.argv[1]
del sys.argv[1]
if test_filename == 'test_urllib2_localnet.py' and os.environ.get('APPVEYOR'):
os.environ['GEVENT_DEBUG'] = 'TRACE'
print('Running with patch_all(): %s' % (test_filename,))
from gevent import monkey
# Only test the default set of patch arguments.... | 5,406 | 35.288591 | 98 | py |
gevent | gevent-master/src/gevent/testing/leakcheck.py | # Copyright (c) 2018 gevent community
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, di... | 8,227 | 34.465517 | 105 | py |
gevent | gevent-master/src/gevent/testing/resources.py | # -*- coding: utf-8 -*-
# Copyright (c) 2018 gevent community
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, mo... | 7,481 | 34.628571 | 88 | py |
gevent | gevent-master/src/gevent/testing/skipping.py | # Copyright (c) 2018 gevent community
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, di... | 6,860 | 32.965347 | 85 | py |
gevent | gevent-master/src/gevent/testing/testrunner.py | #!/usr/bin/env python
from __future__ import print_function, absolute_import, division
import re
import sys
import os
import glob
import operator
import traceback
import importlib
from contextlib import contextmanager
from datetime import timedelta
from multiprocessing.pool import ThreadPool
from multiprocessing impo... | 35,705 | 35.659138 | 103 | py |
gevent | gevent-master/src/gevent/testing/modules.py | # Copyright (c) 2018 gevent community
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, di... | 4,708 | 34.406015 | 91 | py |
gevent | gevent-master/src/gevent/testing/testcase.py | # Copyright (c) 2018 gevent community
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, di... | 17,537 | 36.961039 | 108 | py |
gevent | gevent-master/src/gevent/testing/six.py | import sys
# pylint:disable=unused-argument,import-error
PY2 = sys.version_info[0] == 2
PY3 = sys.version_info[0] >= 3
if PY3:
import builtins
exec_ = getattr(builtins, "exec")
def reraise(tp, value, tb=None):
if value.__traceback__ is not tb:
raise value.with_traceback(tb)
ra... | 1,035 | 22.545455 | 45 | py |
gevent | gevent-master/src/gevent/testing/exception.py | # Copyright (c) 2018 gevent community
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, di... | 1,265 | 51.75 | 79 | py |
gevent | gevent-master/src/gevent/testing/sockets.py | # Copyright (c) 2018 gevent community
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, di... | 2,285 | 44.72 | 88 | py |
gevent | gevent-master/src/gevent/testing/hub.py | # Copyright (c) 2018 gevent community
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, di... | 3,116 | 42.291667 | 90 | py |
gevent | gevent-master/src/gevent/testing/support.py | # Copyright (c) 2018 gevent community
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, di... | 4,875 | 31.945946 | 104 | py |
gevent | gevent-master/src/gevent/testing/timing.py | # Copyright (c) 2018 gevent community
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, di... | 4,982 | 34.848921 | 91 | py |
gevent | gevent-master/src/gevent/testing/errorhandler.py | # Copyright (c) 2018 gevent community
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, di... | 2,329 | 39.172414 | 79 | py |
gevent | gevent-master/src/gevent/testing/util.py | from __future__ import print_function, absolute_import, division
import re
import sys
import os
import traceback
import unittest
import threading
import subprocess
from time import sleep
from . import six
from gevent._config import validate_bool
from gevent._compat import perf_counter
from gevent.monkey import get_ori... | 18,607 | 27.984424 | 105 | py |
gevent | gevent-master/src/gevent/testing/patched_tests_setup.py | # pylint:disable=missing-docstring,invalid-name,too-many-lines
from __future__ import print_function, absolute_import, division
import collections
import contextlib
import functools
import sys
import os
# At least on 3.6+, importing platform
# imports subprocess, which imports selectors. That
# can expose issues with ... | 57,621 | 41.873512 | 123 | py |
gevent | gevent-master/src/gevent/testing/__init__.py | # Copyright (c) 2008-2009 AG Projects
# Copyright 2018 gevent community
# Author: Denis Bilenko
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limita... | 5,602 | 28.803191 | 79 | py |
gevent | gevent-master/src/gevent/testing/params.py | # Copyright (c) 2018 gevent community
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, di... | 2,674 | 37.768116 | 79 | py |
gevent | gevent-master/src/gevent/testing/sysinfo.py | # Copyright (c) 2018 gevent community
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, di... | 7,189 | 31.533937 | 89 | py |
gevent | gevent-master/src/gevent/testing/switching.py | # Copyright (c) 2018 gevent community
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, di... | 2,708 | 40.676923 | 104 | py |
gevent | gevent-master/src/gevent/testing/flaky.py | # Copyright (c) 2018 gevent community
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, di... | 4,104 | 34.695652 | 83 | py |
gevent | gevent-master/src/gevent/testing/coveragesite/sitecustomize.py | # When testrunner.py is invoked with --coverage, it puts this first
# on the path as per https://coverage.readthedocs.io/en/coverage-4.0b3/subprocess.html.
# Note that this disables other sitecustomize.py files.
import coverage
try:
coverage.process_startup()
except coverage.CoverageException as e:
if str(e) ==... | 558 | 30.055556 | 96 | py |
gevent | gevent-master/src/gevent/tests/test___monitor.py | # Copyright 2018 gevent contributors. See LICENSE for details.
import gc
import unittest
from greenlet import gettrace
from greenlet import settrace
from gevent.monkey import get_original
from gevent._compat import thread_mod_name
from gevent._compat import NativeStrIO
from gevent.testing import verify
from gevent... | 12,624 | 31.622739 | 94 | py |
gevent | gevent-master/src/gevent/tests/test__monkey_sigchld.py | import errno
import os
import sys
import gevent
import gevent.monkey
gevent.monkey.patch_all()
pid = None
awaiting_child = []
def handle_sigchld(*_args):
# Make sure we can do a blocking operation
gevent.sleep()
# Signal completion
awaiting_child.pop()
# Raise an ignored error
raise TypeErro... | 2,939 | 31.666667 | 96 | py |
gevent | gevent-master/src/gevent/tests/test__monkey_builtins_future.py | # Under Python 2, if the `future` module is installed, we get
# a `builtins` module, which mimics the `builtins` module from
# Python 3, but does not have the __import__ and some other functions.
# Make sure we can still run in that case.
import sys
try:
# fake out a "broken" builtins module
import builtins
ex... | 521 | 29.705882 | 70 | py |
gevent | gevent-master/src/gevent/tests/test__getaddrinfo_import.py | # On Python 2, a deadlock is possible if we import a module that runs gevent's getaddrinfo
# with a unicode hostname, which starts Python's getaddrinfo on a thread, which
# attempts to import encodings.idna but blocks on the import lock. Verify
# that gevent avoids this deadlock.
import getaddrinfo_module # pylint:dis... | 377 | 46.25 | 90 | py |
gevent | gevent-master/src/gevent/tests/test__threading_patched_local.py | from gevent import monkey; monkey.patch_all()
import threading
localdata = threading.local()
localdata.x = "hello"
assert localdata.x == 'hello'
success = []
def func():
try:
getattr(localdata, 'x')
raise AssertionError('localdata.x must raise AttributeError')
except AttributeError:
... | 675 | 23.142857 | 69 | py |
gevent | gevent-master/src/gevent/tests/test__subprocess_poll.py | import sys
# XXX: Handle this more automatically. See comments in the testrunner.
from gevent.testing.resources import exit_without_resource
exit_without_resource('subprocess')
from gevent.subprocess import Popen
from gevent.testing.util import alarm
alarm(3)
popen = Popen([sys.executable, '-c', 'pass'])
while popen... | 346 | 23.785714 | 70 | py |
gevent | gevent-master/src/gevent/tests/test__api_timeout.py | # Copyright (c) 2008 AG Projects
# Author: Denis Bilenko
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify,... | 6,323 | 28.971564 | 91 | py |
gevent | gevent-master/src/gevent/tests/test__threading_vs_settrace.py | from __future__ import print_function
import sys
import subprocess
import unittest
from gevent.thread import allocate_lock
import gevent.testing as greentest
script = """
from gevent import monkey
monkey.patch_all() # pragma: testrunner-no-monkey-combine
import sys, os, threading, time
# A deadlock-killer, to preven... | 5,023 | 29.822086 | 103 | py |
gevent | gevent-master/src/gevent/tests/_imports_at_top_level.py | # We simply import a stdlib module
__import__('netrc')
| 55 | 17.666667 | 34 | py |
gevent | gevent-master/src/gevent/tests/test__resolver_dnspython.py | # -*- coding: utf-8 -*-
"""
Tests explicitly using the DNS python resolver.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import sys
import unittest
import subprocess
import os
from gevent import testing as greentest
@unittest.skipUnless(greentest.r... | 1,117 | 24.409091 | 66 | py |
gevent | gevent-master/src/gevent/tests/test__thread.py | from __future__ import print_function
from __future__ import absolute_import
from gevent.thread import allocate_lock
import gevent.testing as greentest
try:
from _thread import allocate_lock as std_allocate_lock
except ImportError: # Py2
from thread import allocate_lock as std_allocate_lock
class TestLock(... | 780 | 23.40625 | 58 | py |
gevent | gevent-master/src/gevent/tests/test__socket_send_memoryview.py | # See issue #466
import unittest
import ctypes
import gevent.testing as greentest
class AnStructure(ctypes.Structure):
_fields_ = [("x", ctypes.c_int)]
def _send(socket):
for meth in ('sendall', 'send'):
anStructure = AnStructure()
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
... | 960 | 22.439024 | 63 | py |
gevent | gevent-master/src/gevent/tests/test__issue112.py | import sys
import unittest
import threading
import gevent
import gevent.monkey
gevent.monkey.patch_all()
@unittest.skipUnless(
sys.version_info[0] == 2,
"Only on Python 2"
)
class Test(unittest.TestCase):
def test(self):
self.assertIs(threading._sleep, gevent.sleep)
if __name__ == '__main__':
... | 338 | 15.95 | 53 | py |
gevent | gevent-master/src/gevent/tests/test__compat.py | from __future__ import absolute_import, print_function, division
import os
import unittest
class TestFSPath(unittest.TestCase):
def setUp(self):
self.__path = None
def __fspath__(self):
if self.__path is not None:
return self.__path
raise AttributeError("Accessing path da... | 1,439 | 24.263158 | 69 | py |
gevent | gevent-master/src/gevent/tests/test__event.py | from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
import weakref
import gevent
from gevent.event import Event, AsyncResult
import gevent.testing as greentest
from gevent.testing.six import xrange
from gevent.testing.timing import AbstractGenericGetTestCase
... | 14,176 | 30.57461 | 95 | py |
gevent | gevent-master/src/gevent/tests/__main__.py | #!/usr/bin/env python
from __future__ import print_function, absolute_import, division
if __name__ == '__main__':
from gevent.testing import testrunner
testrunner.main()
| 179 | 24.714286 | 64 | py |
gevent | gevent-master/src/gevent/tests/test__close_backend_fd.py | from __future__ import print_function
import os
import unittest
import gevent
from gevent import core
from gevent.hub import Hub
from gevent.testing import sysinfo
@unittest.skipUnless(
getattr(core, 'LIBEV_EMBED', False),
"Needs embedded libev. "
"hub.loop.fileno is only defined when "
"we embed lib... | 3,104 | 30.05 | 74 | py |
gevent | gevent-master/src/gevent/tests/test__issue467.py | import gevent
from gevent import testing as greentest
#import socket # on windows
# iwait should not raise `LoopExit: This operation would block forever`
# or `AssertionError: Invalid switch into ...`
# if the caller of iwait causes greenlets to switch in between
# return values
def worker(i):
# Have one of the... | 1,205 | 28.414634 | 71 | py |
gevent | gevent-master/src/gevent/tests/test__joinall.py | import gevent
from gevent import testing as greentest
class Test(greentest.TestCase):
def test(self):
def func():
pass
a = gevent.spawn(func)
b = gevent.spawn(func)
gevent.joinall([a, b, a])
if __name__ == '__main__':
greentest.main()
| 296 | 13.142857 | 39 | py |
gevent | gevent-master/src/gevent/tests/test__example_udp_server.py | import socket
from gevent.testing import util
from gevent.testing import main
class Test(util.TestServer):
example = 'udp_server.py'
def _run_all_tests(self):
sock = socket.socket(type=socket.SOCK_DGRAM)
try:
sock.connect(('127.0.0.1', 9000))
sock.send(b'Test udp_serv... | 513 | 21.347826 | 56 | py |
gevent | gevent-master/src/gevent/tests/test__socket_dns.py | #!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
import gevent
from gevent import monkey
import os
import re
import unittest
import socket
from time import time
import traceback
import gevent.socket as gevent_socket... | 36,582 | 37.147028 | 110 | py |
gevent | gevent-master/src/gevent/tests/test__greenlet.py | # Copyright (c) 2008-2009 AG Projects
# Author: Denis Bilenko
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, mo... | 31,759 | 29.955166 | 115 | py |
gevent | gevent-master/src/gevent/tests/test__order.py | import gevent
import gevent.testing as greentest
from gevent.testing.six import xrange
class appender(object):
def __init__(self, lst, item):
self.lst = lst
self.item = item
def __call__(self, *args):
self.lst.append(self.item)
class Test(greentest.TestCase):
count = 2
de... | 1,125 | 17.16129 | 75 | py |
gevent | gevent-master/src/gevent/tests/test__timeout.py | import gevent.testing as greentest
import gevent
from gevent.hub import get_hub
import sys
SHOULD_EXPIRE = 0.01
if not greentest.RUNNING_ON_CI:
SHOULD_NOT_EXPIRE = SHOULD_EXPIRE * 2.0
else:
SHOULD_NOT_EXPIRE = SHOULD_EXPIRE * 20.0
class TestDirectRaise(greentest.TestCase):
switch_expected = False
de... | 5,243 | 31.775 | 104 | py |
gevent | gevent-master/src/gevent/tests/test__api.py | # Copyright (c) 2008 AG Projects
# Author: Denis Bilenko
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify,... | 4,550 | 33.218045 | 95 | py |
gevent | gevent-master/src/gevent/tests/test__socket_dns6.py | #!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import print_function, absolute_import, division
import socket
import unittest
import gevent.testing as greentest
from gevent.tests.test__socket_dns import TestCase, add
from gevent.testing.sysinfo import OSX
from gevent.testing.sysinfo import RESOLVER_DNSPYT... | 3,716 | 31.321739 | 83 | py |
gevent | gevent-master/src/gevent/tests/test__example_webproxy.py | from unittest import SkipTest
import gevent.testing as greentest
from . import test__example_wsgiserver
@greentest.skipOnCI("Timing issues sometimes lead to a connection refused")
@greentest.skipWithoutExternalNetwork("Tries to reach google.com")
class Test_webproxy(test__example_wsgiserver.Test_wsgiserver):
e... | 807 | 25.933333 | 75 | py |
gevent | gevent-master/src/gevent/tests/test__threading_native_before_monkey.py | # If stdlib threading is imported *BEFORE* monkey patching, *and*
# there is a native thread created, we can still get the current
# (main) thread, and it's not a DummyThread.
# Joining the native thread also does not fail
import threading
from time import sleep as time_sleep
import gevent.testing as greentest
class... | 2,042 | 28.608696 | 82 | py |
gevent | gevent-master/src/gevent/tests/test__monkey_multiple_imports.py | # https://github.com/gevent/gevent/issues/615
# Under Python 3, with its use of importlib,
# if the monkey patch is done when the importlib import lock is held
# (e.g., during recursive imports) we could fail to release the lock.
# This is surprisingly common.
__import__('_import_import_patch')
| 296 | 41.428571 | 69 | py |
gevent | gevent-master/src/gevent/tests/test__threading_2.py | # testing gevent's Event, Lock, RLock, Semaphore, BoundedSemaphore with standard test_threading
from __future__ import print_function
from gevent.testing.six import xrange
import gevent.testing as greentest
setup_ = '''from gevent import monkey; monkey.patch_all()
from gevent.event import Event
from gevent.lock impor... | 23,066 | 36.144928 | 149 | py |
gevent | gevent-master/src/gevent/tests/test__core_timer.py | from __future__ import print_function
from gevent import config
import gevent.testing as greentest
from gevent.testing import TestCase
from gevent.testing import LARGE_TIMEOUT
from gevent.testing.sysinfo import CFFI_BACKEND
from gevent.testing.flaky import reraises_flaky_timeout
class Test(TestCase):
__timeout__... | 4,330 | 26.411392 | 79 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.