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

Skip to content

Commit 465cf16

Browse files
authored
Merge pull request 0rpc#246 from chombourger/issue-231
try collections.abc instead of collections for Python >= 3.4
2 parents 3d0a6ee + c43ac74 commit 465cf16

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

tests/test_reqstream.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,17 @@
2828
from builtins import range
2929

3030
import gevent
31-
import collections
3231

3332
import zerorpc
3433
from .testutils import teardown, random_ipc_endpoint, TIME_FACTOR
3534

35+
try:
36+
# Try collections.abc for 3.4+
37+
from collections.abc import Iterator
38+
except ImportError:
39+
# Fallback to collections for Python 2
40+
from collections import Iterator
41+
3642

3743
def test_rcp_streaming():
3844
endpoint = random_ipc_endpoint()
@@ -58,7 +64,7 @@ def xrange(self, max):
5864
assert list(r) == list(range(10))
5965

6066
r = client.xrange(10)
61-
assert isinstance(r, collections.Iterator)
67+
assert isinstance(r, Iterator)
6268
l = []
6369
print('wait 4s for fun')
6470
gevent.sleep(TIME_FACTOR * 4)

zerorpc/cli.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,17 @@
3333
import inspect
3434
import os
3535
import logging
36-
import collections
3736
from pprint import pprint
3837

3938
import zerorpc
4039

40+
try:
41+
# Try collections.abc for 3.4+
42+
from collections.abc import Iterator
43+
except ImportError:
44+
# Fallback to collections for Python 2
45+
from collections import Iterator
46+
4147

4248
parser = argparse.ArgumentParser(
4349
description='Make a zerorpc call to a remote service.'
@@ -267,7 +273,7 @@ def run_client(args):
267273
else:
268274
call_args = args.params
269275
results = client(args.command, *call_args)
270-
if not isinstance(results, collections.Iterator):
276+
if not isinstance(results, Iterator):
271277
if args.print_json:
272278
json.dump(results, sys.stdout)
273279
else:

0 commit comments

Comments
 (0)