Skip to content

Commit

Permalink
remove gevent & deprecated contract filter methods
Browse files Browse the repository at this point in the history
  • Loading branch information
carver committed Nov 10, 2017
1 parent c2bc8c6 commit 33772b7
Show file tree
Hide file tree
Showing 16 changed files with 55 additions and 365 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ matrix:
# core-stdlib
- python: "3.5"
env: TOX_POSARGS="-e py35-core-stdlib"
# core-gevent
- python: "3.5"
env: TOX_POSARGS="-e py35-core-gevent"
# eth-testrpc
- python: "3.5"
env: TOX_POSARGS="-e py35-integration-ethtestrpc"
Expand Down
5 changes: 0 additions & 5 deletions docs/filters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ Filter API

.. py:class:: Filter(web3, filter_id)
The :py:class::`Filter` object is a subclass of the
:py:class::`gevent.Greenlet` object. It exposes these additional properties
and methods.


.. py:attribute:: Filter.filter_id
The ``filter_id`` for this filter as returned by the ``eth_newFilter`` RPC
Expand Down
10 changes: 0 additions & 10 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@ Or to install with support for the ``TestRPCProvider`` and
$ pip install web3[tester]
Or to install with support for gevent based threading:

.. code-block:: shell
$ pip install web3[gevent]
To enable gevent based threading set the environment variable ``THREADING_BACKEND=gevent``


Installation from source can be done from the root of the project with the
following command.

Expand Down
1 change: 0 additions & 1 deletion requirements-docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ configparser==3.5.0
contextlib2>=0.5.4
#eth-testrpc>=0.8.0
#ethereum-tester-client>=1.1.0
gevent>=1.1.2
py-geth>=1.4.0
py-solc>=0.4.0
#pysha3>=0.3
Expand Down
2 changes: 0 additions & 2 deletions requirements-gevent.txt

This file was deleted.

4 changes: 0 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@
setup_requires=['setuptools-markdown'],
extras_require={
'tester': ["eth-testrpc>=1.3.3"],
'gevent': [
"gevent>=1.1.1,<1.2.0",
"geventhttpclient>=1.3.1",
],
},
py_modules=['web3', 'ens'],
license="MIT",
Expand Down
35 changes: 35 additions & 0 deletions tests/core/filtering/test_contract_on_event_filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ def test_on_filter_using_get_entries_interface(web3,
emitter_log_topics,
emitter_event_ids,
call_as_instance):
if True:
assert not hasattr(Emitter, 'eventFilter')
# once this fails, reimplement the test with the new API
return

if call_as_instance:
filter = emitter.on('LogNoArguments', {})
else:
Expand Down Expand Up @@ -47,6 +52,11 @@ def test_on_filter_using_get_interface(web3,
emitter_log_topics,
emitter_event_ids,
call_as_instance):
if True:
assert not hasattr(Emitter, 'eventFilter')
# once this fails, reimplement the test with the new API
return

if call_as_instance:
filter = emitter.on('LogNoArguments', {})
else:
Expand Down Expand Up @@ -75,6 +85,11 @@ def test_on_filter_with_only_event_name(web3,
emitter_log_topics,
emitter_event_ids,
call_as_instance):
if True:
assert not hasattr(Emitter, 'eventFilter')
# once this fails, reimplement the test with the new API
return

seen_logs = []

if call_as_instance:
Expand Down Expand Up @@ -106,6 +121,11 @@ def test_on_async_filter_with_event_name_and_single_argument(web3,
emitter_event_ids,
call_as_instance
):
if True:
assert not hasattr(Emitter, 'eventFilter')
# once this fails, reimplement the test with the new API
return

seen_logs = []

if call_as_instance:
Expand Down Expand Up @@ -151,6 +171,11 @@ def test_on_async_filter_with_event_name_and_non_indexed_argument(web3,
emitter_event_ids,
call_as_instance
):
if True:
assert not hasattr(Emitter, 'eventFilter')
# once this fails, reimplement the test with the new API
return

seen_logs = []

if call_as_instance:
Expand Down Expand Up @@ -196,6 +221,11 @@ def test_on_sync_filter_with_event_name_and_single_argument(web3,
emitter_event_ids,
call_as_instance
):
if True:
assert not hasattr(Emitter, 'eventFilter')
# once this fails, reimplement the test with the new API
return

if call_as_instance:
filter = emitter.on('LogTripleWithIndex', {'filter': {
'arg1': 2,
Expand Down Expand Up @@ -238,6 +268,11 @@ def test_on_sync_filter_with_event_name_and_non_indexed_argument(web3,
emitter_event_ids,
call_as_instance
):
if True:
assert not hasattr(Emitter, 'eventFilter')
# once this fails, reimplement the test with the new API
return

if call_as_instance:
filter = emitter.on('LogTripleWithIndex', {'filter': {
'arg0': 1, 'arg1': 2,
Expand Down
15 changes: 15 additions & 0 deletions tests/core/filtering/test_contract_past_event_filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ def test_past_events_async_filter_with_callback(web3,
emitter_event_ids,
call_as_instance
):
if True:
assert not hasattr(Emitter, 'eventFilter')
# once this fails, reimplement the test with the new API
return

txn_hash = emitter.transact().logNoArgs(emitter_event_ids.LogNoArguments)
txn_receipt = wait_for_transaction(web3, txn_hash)

Expand Down Expand Up @@ -60,6 +65,11 @@ def test_past_events_filter_using_get_api(web3,
emitter_log_topics,
emitter_event_ids,
call_as_instance):
if True:
assert not hasattr(Emitter, 'eventFilter')
# once this fails, reimplement the test with the new API
return

txn_hash = emitter.transact().logNoArgs(emitter_event_ids.LogNoArguments)
txn_receipt = wait_for_transaction(web3, txn_hash)

Expand Down Expand Up @@ -94,6 +104,11 @@ def test_past_events_filter_using_get_entries_api(web3,
emitter_log_topics,
emitter_event_ids,
call_as_instance):
if True:
assert not hasattr(Emitter, 'eventFilter')
# once this fails, reimplement the test with the new API
return

txn_hash = emitter.transact().logNoArgs(emitter_event_ids.LogNoArguments)
txn_receipt = wait_for_transaction(web3, txn_hash)

Expand Down
31 changes: 0 additions & 31 deletions tests/core/filtering/test_filter_deprecations.py

This file was deleted.

11 changes: 0 additions & 11 deletions tests/core/filtering/test_filter_running_is_set_immediately.py

This file was deleted.

2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tox]
envlist=
py35-ens
py35-core-{gevent,stdlib}
py35-core-stdlib
py35-integration-{ethtestrpc,goethereum,ethtester}
flake8

Expand Down
73 changes: 0 additions & 73 deletions web3/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,9 @@
from web3.utils.encoding import (
to_hex,
)
from web3.utils.events import (
get_event_data,
)
from web3.utils.exception import (
raise_from,
)
from web3.utils.filters import (
construct_event_filter_params,
PastLogFilter,
)
from web3.utils.normalizers import (
BASE_RETURN_NORMALIZERS,
abi_address_to_hex,
Expand Down Expand Up @@ -259,72 +252,6 @@ def encodeABI(cls, fn_name, args=None, kwargs=None, data=None):

return cls._encode_abi(fn_abi, fn_arguments, data)

@combomethod
def on(self, event_name, filter_params=None, *callbacks):
"""
Register a callback to be triggered on the appropriate events.
"""
if filter_params is None:
filter_params = {}

argument_filters = filter_params.pop('filter', {})
argument_filter_names = list(argument_filters.keys())
event_abi = self._find_matching_event_abi(
event_name,
argument_filter_names,
)

data_filter_set, event_filter_params = construct_event_filter_params(
event_abi,
contract_address=self.address,
argument_filters=argument_filters,
**filter_params
)

log_data_extract_fn = functools.partial(get_event_data, event_abi)

log_filter = self.web3.eth.filter(event_filter_params)

log_filter.set_data_filters(data_filter_set)
log_filter.log_entry_formatter = log_data_extract_fn
log_filter.filter_params = event_filter_params

if callbacks:
log_filter.watch(*callbacks)

return log_filter

@combomethod
def pastEvents(self, event_name, filter_params=None, *callbacks):
"""
Register a callback to be triggered on all past events.
"""
if filter_params is None:
filter_params = {}

event_filter_params = {}
event_filter_params.update(filter_params)
event_filter_params.setdefault('fromBlock', 'earliest')
event_filter_params.setdefault('toBlock', self.web3.eth.blockNumber)

log_filter = self.on(
event_name,
filter_params=event_filter_params,
)

past_log_filter = PastLogFilter(
web3=log_filter.web3,
filter_id=log_filter.filter_id,
log_entry_formatter=log_filter.log_entry_formatter,
data_filter_set=log_filter.data_filter_set,
)
past_log_filter.filter_params = log_filter.filter_params

if callbacks:
past_log_filter.watch(*callbacks)

return past_log_filter

@combomethod
def estimateGas(self, transaction=None):
"""
Expand Down
19 changes: 3 additions & 16 deletions web3/utils/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,17 @@ def get_threading_backend():


if THREADING_BACKEND == 'stdlib':
from .compat_stdlib import (
from .compat_stdlib import ( # noqa: F401
Timeout,
sleep,
socket,
threading,
make_server,
GreenletThread,
spawn,
subprocess,
)
from .compat_requests import (
make_post_request,
)
elif THREADING_BACKEND == 'gevent':
from .compat_gevent import ( # noqa: F401
Timeout,
sleep,
socket,
threading,
make_server,
GreenletThread,
spawn,
subprocess,
from .compat_requests import ( # noqa: F401
make_post_request,
)
else:
raise ValueError("Unsupported threading backend. Must be one of 'gevent' or 'stdlib'")
raise ValueError("Unsupported threading backend. Must be 'stdlib'")
Loading

0 comments on commit 33772b7

Please sign in to comment.