This repository has been archived by the owner on Nov 23, 2017. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 178
Change import statements to import only what's needed #468
Open
denisra
wants to merge
4
commits into
python:master
Choose a base branch
from
denisra:issue464
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3863b43
Changed all the import statements in all modules in the examples
denisra 5e4efd7
Some minor improvements on coding style.
denisra a40fe76
Changed how we are importing the test_utils submodule as suggested
denisra b92866f
Changed the import statements so they are sorted alphabetically
denisra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,12 @@ | |
""" | ||
|
||
import argparse | ||
import asyncio | ||
from asyncio import test_utils | ||
import json | ||
import logging | ||
|
||
import asyncio | ||
|
||
|
||
ARGS = argparse.ArgumentParser(description='Cache client example.') | ||
ARGS.add_argument( | ||
'--tls', action='store_true', dest='tls', | ||
|
@@ -106,7 +107,7 @@ def activity(self): | |
self.reader, self.writer = yield from asyncio.open_connection( | ||
self.host, self.port, ssl=self.sslctx, loop=self.loop) | ||
except Exception as exc: | ||
backoff = min(args.max_backoff, backoff + (backoff//2) + 1) | ||
backoff = min(args.max_backoff, backoff + (backoff // 2) + 1) | ||
logging.info('Error connecting: %r; sleep %s', exc, backoff) | ||
yield from asyncio.sleep(backoff, loop=self.loop) | ||
continue | ||
|
@@ -172,7 +173,7 @@ def main(): | |
loop = asyncio.new_event_loop() | ||
sslctx = None | ||
if args.tls: | ||
sslctx = test_utils.dummy_ssl_context() | ||
sslctx = asyncio.test_utils.dummy_ssl_context() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unless it's documented as such, there's no guarantee this will hold in the future. It would be better to import |
||
cache = CacheClient(args.host, args.port, sslctx=sslctx, loop=loop) | ||
try: | ||
loop.run_until_complete( | ||
|
@@ -191,7 +192,7 @@ def w(g): | |
|
||
key = 'foo-%s' % label | ||
while True: | ||
logging.info('%s %s', label, '-'*20) | ||
logging.info('%s %s', label, '-' * 20) | ||
try: | ||
ret = yield from w(cache.set(key, 'hello-%s-world' % label)) | ||
logging.info('%s set %s', label, ret) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imports should be sorted alphabetically (that's what we try to do in asyncio and CPython code bases).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@1st1 I wasn't aware of that, sorry. I was going by the PEP8 guidelines, where it tells us to import the standard library modules first. But I'll have that fix following your recommendations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@denisra Asyncio is technically a stdlib module. ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SethMichaelLarson I can't say that it isn't :) will send send in another commit in just a few min with that fixed