Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4dcb6aa

Browse filesBrowse files
committed
ch22: examples
1 parent 98b8cfd commit 4dcb6aa
Copy full SHA for 4dcb6aa

File tree

Expand file treeCollapse file tree

2 files changed

+9
-9
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+9
-9
lines changed

‎22-asyncio/domains/netaddr.py

Copy file name to clipboardExpand all lines: 22-asyncio/domains/netaddr.py
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@
55

66

77
class Result(NamedTuple):
8-
name: str
8+
domain: str
99
found: bool
1010

1111

12-
async def probe(loop: asyncio.AbstractEventLoop, name: str) -> Result:
12+
async def probe(loop: asyncio.AbstractEventLoop, domain: str) -> Result:
1313
try:
14-
await loop.getaddrinfo(name, None)
14+
await loop.getaddrinfo(domain, None)
1515
except socket.gaierror:
16-
return Result(name, False)
17-
return Result(name, True)
16+
return Result(domain, False)
17+
return Result(domain, True)
1818

1919

20-
async def multi_probe(names: Iterable[str]) -> AsyncIterator[Result]:
20+
async def multi_probe(domains: Iterable[str]) -> AsyncIterator[Result]:
2121
loop = asyncio.get_running_loop()
22-
coros = [probe(loop, name) for name in names]
22+
coros = [probe(loop, domain) for domain in domains]
2323
for coro in asyncio.as_completed(coros):
2424
result = await coro
2525
yield result

‎22-asyncio/domains/probe.py

Copy file name to clipboardExpand all lines: 22-asyncio/domains/probe.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ async def main(tld: str) -> None:
1111
tld = tld.strip('.')
1212
names = (kw for kw in kwlist if len(kw) <= 4)
1313
domains = (f'{name}.{tld}'.lower() for name in names)
14-
async for name, found in multi_probe(domains):
14+
async for domain, found in multi_probe(domains):
1515
mark = '.' if found else '?\t\t'
16-
print(f'{mark} {name}')
16+
print(f'{mark} {domain}')
1717

1818

1919
if __name__ == '__main__':

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.