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

Skip to content

core: handle both "async" and "asynchronous" in remote calls #245

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
6 changes: 3 additions & 3 deletions tests/test_client_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def add(self, a, b):
client = zerorpc.Client(timeout=TIME_FACTOR * 2)
client.connect(endpoint)

async_result = client.add(1, 4, async=True)
async_result = client.add(1, 4, async_=True)

if sys.version_info < (2, 7):
def _do_with_assert_raises():
Expand Down Expand Up @@ -84,8 +84,8 @@ def add(self, a, b):
client = zerorpc.Client()
client.connect(endpoint)

async_result = client.lolita(async=True)
async_result = client.lolita(async_=True)
assert async_result.get() == 42

async_result = client.add(1, 4, async=True)
async_result = client.add(1, 4, async_=True)
assert async_result.get() == 5
5 changes: 4 additions & 1 deletion zerorpc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,10 @@ def __call__(self, method, *args, **kargs):
self._context.hook_client_before_request(request_event)
bufchan.emit_event(request_event)

if kargs.get('async', False) is False:
# In python 3.7, "async" is a reserved keyword, clients should now use
# "async_": support both for the time being
if (kargs.get('async', False) is False and
kargs.get('async_', False) is False):
return self._process_response(request_event, bufchan, timeout)

async_result = gevent.event.AsyncResult()
Expand Down