Skip to content

Commit ff00dc7

Browse files
author
daniel.li
committed
[UPDATE]modify examples/client
1 parent 09b2f8c commit ff00dc7

17 files changed

+38
-35
lines changed

.DS_Store

6 KB
Binary file not shown.

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ install:
2929
- pip install -e .
3030

3131
script:
32-
- pyflakes aionsq tests
33-
- pep8 aionsq tests
32+
- pyflakes asyncnsq tests
33+
- pep8 asyncnsq tests
3434
- python runtests.py -v

Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ doc:
99
make -C docs html
1010

1111
flake:
12-
$(FLAKE) aionsq tests examples
13-
$(PEP) aionsq tests examples
12+
$(FLAKE) asyncnsq tests examples
13+
$(PEP) asyncnsq tests examples
1414

1515
test:
1616
$(PYTHON) runtests.py -v 4
@@ -19,7 +19,7 @@ cov coverage:
1919
$(PYTHON) runtests.py --coverage
2020

2121
dist:
22-
-rm -r build dist aionsq.egg-info
22+
-rm -r build dist asyncnsq.egg-info
2323
$(PYTHON) setup.py sdist bdist_wheel
2424

2525
clean:
@@ -34,4 +34,4 @@ clean:
3434
rm -f .coverage
3535
rm -rf coverage
3636
rm -rf docs/_build
37-
rm -rf build dist aionsq.egg-info
37+
rm -rf build dist asyncnsq.egg-info

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ implement python3.5+ async/await syntax support
55

66
提供python3.5+ async/await 语法支持。 原项目,支持yield from 生成器语法。
77

8-
this project is forked from jettify/aionsq, he is the original author
8+
this project is forked from jettify/asyncnsq, he is the original author
99

10-
本项目fork了 jettify/aionsq, 他是原作者,但是很久没有更新了。
10+
本项目fork了 jettify/asyncnsq, 他是原作者,但是很久没有更新了。
1111

1212
Usage examples
1313
--------------

asyncnsq/consumer.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import random
33
from collections import deque
44
import time
5-
from aionsq.http import NsqLookupd
6-
from aionsq.nsq import create_nsq
7-
from aionsq.utils import RdyControl
5+
from asyncnsq.http import NsqLookupd
6+
from asyncnsq.nsq import create_nsq
7+
from asyncnsq.utils import RdyControl
88

99

1010
class NsqConsumer:

examples/client.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import asyncio
2+
import sys
3+
import os
4+
sys.path.append(os.getcwd())
25
from asyncnsq.consumer import NsqConsumer
36
from asyncnsq.nsq import create_nsq
47

@@ -8,7 +11,7 @@ def main():
811
loop = asyncio.get_event_loop()
912

1013
async def go():
11-
nsq_producer = await create_nsq(host='127.0.0.1', port=4150,
14+
nsq_producer = await create_nsq(host='10.64.147.3', port=4150,
1215
heartbeat_interval=30000,
1316
feature_negotiation=True,
1417
tls_v1=True,
@@ -17,12 +20,12 @@ async def go():
1720
deflate_level=0,
1821
loop=loop)
1922
for i in range(0, 35):
20-
await nsq_producer.pub('test_asyncnsq', 'xxx:{i}'.format(i=i))
23+
await nsq_producer.pub('test_async_nsq', 'xxx:{i}'.format(i=i))
2124

22-
endpoints = [('127.0.0.1', 4150)]
25+
endpoints = [('10.64.147.3', 4150)]
2326
nsq_consumer = NsqConsumer(nsqd_tcp_addresses=endpoints, loop=loop)
2427
await nsq_consumer.connect()
25-
await nsq_consumer.subscribe('test_asyncnsq', 'nsq')
28+
await nsq_consumer.subscribe('test_async_nsq', 'nsq')
2629
for waiter in nsq_consumer.wait_messages():
2730
message = await waiter
2831
print(message.body)

examples/conn.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import asyncio
2-
from aionsq.nsq import create_nsq
2+
from asyncnsq.nsq import create_nsq
33

44

55
def main():

examples/simple.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import asyncio
2-
from aionsq.connection import create_connection
2+
from asyncnsq.connection import create_connection
33

44

55
def main():

runtests.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
"""Run aionsq unittests.
2+
"""Run asyncnsq unittests.
33
44
Usage:
55
python3 runtests.py [flags] [pattern] ...
@@ -241,7 +241,7 @@ def runtests():
241241

242242
if args.coverage:
243243
cov = coverage.coverage(branch=True,
244-
source=['aionsq'],
244+
source=['asyncnsq'],
245245
)
246246
cov.start()
247247

setup.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
elif PY_VER >= (3, 3):
1414
install_requires.append('asyncio')
1515
else:
16-
raise RuntimeError("aionsq doesn't support Python version prior 3.3")
16+
raise RuntimeError("asyncnsq doesn't support Python version prior 3.3")
1717

1818

1919
def read(*parts):
@@ -24,14 +24,14 @@ def read(*parts):
2424
def read_version():
2525
regexp = re.compile(r"^__version__\W*=\W*'([\d.abrc]+)'")
2626
init_py = os.path.join(os.path.dirname(__file__),
27-
'aionsq', '__init__.py')
27+
'asyncnsq', '__init__.py')
2828
with open(init_py) as f:
2929
for line in f:
3030
match = regexp.match(line)
3131
if match is not None:
3232
return match.group(1)
3333
else:
34-
raise RuntimeError('Cannot find version in aionsq/__init__.py')
34+
raise RuntimeError('Cannot find version in asyncnsq/__init__.py')
3535

3636

3737
classifiers = [

tests/test_connection.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import asyncio
22
from ._testutils import run_until_complete, BaseTest
3-
from aionsq.connection import create_connection, NsqConnection
4-
from aionsq.http import Nsqd
5-
from aionsq.protocol import Reader, SnappyReader, DeflateReader
3+
from asyncnsq.connection import create_connection, NsqConnection
4+
from asyncnsq.http import Nsqd
5+
from asyncnsq.protocol import Reader, SnappyReader, DeflateReader
66

77

88
class NsqConnectionTest(BaseTest):

tests/test_http_producer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from ._testutils import run_until_complete, BaseTest
2-
from aionsq.http.rest_producer import create_http_producer
2+
from asyncnsq.http.rest_producer import create_http_producer
33

44

55
class NsqHTTPProducerTest(BaseTest):

tests/test_lookupd.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from ._testutils import run_until_complete, BaseTest
2-
from aionsq.http.lookupd import NsqLookupd
2+
from asyncnsq.http.lookupd import NsqLookupd
33

44

55
class NsqLookupdTest(BaseTest):

tests/test_nsq.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import asyncio
22
from ._testutils import run_until_complete, BaseTest
3-
from aionsq.connection import create_connection, NsqConnection
4-
from aionsq.consumer import NsqConsumer
5-
from aionsq.http import Nsqd
6-
from aionsq.nsq import create_nsq
3+
from asyncnsq.connection import create_connection, NsqConnection
4+
from asyncnsq.consumer import NsqConsumer
5+
from asyncnsq.http import Nsqd
6+
from asyncnsq.nsq import create_nsq
77

88

99
class NsqTest(BaseTest):

tests/test_nsqld.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from ._testutils import run_until_complete, BaseTest
2-
from aionsq.http.nsqd import Nsqd
2+
from asyncnsq.http.nsqd import Nsqd
33

44

55
class NsqdTest(BaseTest):

tests/test_parser.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import unittest
2-
from aionsq.exceptions import ProtocolError
3-
from aionsq.protocol import Reader
2+
from asyncnsq.exceptions import ProtocolError
3+
from asyncnsq.protocol import Reader
44

55

66
class ParserTest(unittest.TestCase):

tests/test_producer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from ._testutils import run_until_complete, BaseTest
2-
from aionsq.producer import create_producer
2+
from asyncnsq.producer import create_producer
33

44

55
class NsqTCPProducerTest(BaseTest):

0 commit comments

Comments
 (0)