Thanks to visit codestin.com
Credit goes to github.com

Skip to content

try collections.abc instead of collections for Python >= 3.4 #246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions tests/test_reqstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,17 @@
from builtins import range

import gevent
import collections

import zerorpc
from .testutils import teardown, random_ipc_endpoint, TIME_FACTOR

try:
# Try collections.abc for 3.4+
from collections.abc import Iterator
except ImportError:
# Fallback to collections for Python 2
from collections import Iterator


def test_rcp_streaming():
endpoint = random_ipc_endpoint()
Expand All @@ -58,7 +64,7 @@ def xrange(self, max):
assert list(r) == list(range(10))

r = client.xrange(10)
assert isinstance(r, collections.Iterator)
assert isinstance(r, Iterator)
l = []
print('wait 4s for fun')
gevent.sleep(TIME_FACTOR * 4)
Expand Down
10 changes: 8 additions & 2 deletions zerorpc/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,17 @@
import inspect
import os
import logging
import collections
from pprint import pprint

import zerorpc

try:
# Try collections.abc for 3.4+
from collections.abc import Iterator
except ImportError:
# Fallback to collections for Python 2
from collections import Iterator


parser = argparse.ArgumentParser(
description='Make a zerorpc call to a remote service.'
Expand Down Expand Up @@ -267,7 +273,7 @@ def run_client(args):
else:
call_args = args.params
results = client(args.command, *call_args)
if not isinstance(results, collections.Iterator):
if not isinstance(results, Iterator):
if args.print_json:
json.dump(results, sys.stdout)
else:
Expand Down