Skip to content

Commit aea357e

Browse files
committed
cap20: revisão de estilo completa
1 parent d4bd41b commit aea357e

File tree

7 files changed

+486
-225
lines changed

7 files changed

+486
-225
lines changed

code/20-executors/demo_executor_map.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ def display(*args): # <1>
1010
print(*args)
1111

1212
def loiter(n): # <2>
13-
msg = '{}loiter({}): doing nothing for {}s...'
13+
msg = '{}loiter({}): napping for {}s...'
1414
display(msg.format('\t'*n, n, n))
1515
sleep(n)
1616
msg = '{}loiter({}): done.'
1717
display(msg.format('\t'*n, n))
18-
return n * 10 # <3>
18+
return n + 10 # <3>
1919

2020
def main():
2121
display('Script starting.')

code/20-executors/getflags/flags2_sequential.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ def get_flag(base_url: str, cc: str) -> bytes:
3535
resp.raise_for_status() # <3>
3636
return resp.content
3737

38-
def download_one(cc: str, base_url: str, verbose: bool = False) -> DownloadStatus:
38+
def download_one(
39+
cc: str,
40+
base_url: str,
41+
verbose: bool = False) -> DownloadStatus:
3942
try:
4043
image = get_flag(base_url, cc)
4144
except httpx.HTTPStatusError as exc: # <4>
@@ -69,7 +72,8 @@ def download_many(cc_list: list[str],
6972
try:
7073
status = download_one(cc, base_url, verbose) # <4>
7174
except httpx.HTTPStatusError as exc: # <5>
72-
error_msg = 'HTTP error {resp.status_code} - {resp.reason_phrase}'
75+
error_msg = ('HTTP error {resp.status_code}' +
76+
' - {resp.reason_phrase}')
7377
error_msg = error_msg.format(resp=exc.response)
7478
except httpx.RequestError as exc: # <6>
7579
error_msg = f'{exc} {type(exc)}'.strip()

code/20-executors/getflags/flags2_threadpool.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ def download_many(cc_list: list[str],
5050
try:
5151
status = future.result() # <12>
5252
except httpx.HTTPStatusError as exc: # <13>
53-
error_msg = 'HTTP error {resp.status_code} - {resp.reason_phrase}'
53+
error_msg = ('HTTP error {resp.status_code}' +
54+
' - {resp.reason_phrase}')
5455
error_msg = error_msg.format(resp=exc.response)
5556
except httpx.RequestError as exc:
5657
error_msg = f'{exc} {type(exc)}'.strip()

code/20-executors/getflags/flags_threadpool_futures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def download_many(cc_list: list[str]) -> int:
2020
to_do.append(future) # <5>
2121
print(f'Scheduled for {cc}: {future}') # <6>
2222

23-
for count, future in enumerate(futures.as_completed(to_do), 1): # <7>
23+
for count, future in enumerate(futures.as_completed(to_do), 1):# <7>
2424
res: str = future.result() # <8>
2525
print(f'{future} result: {res!r}') # <9>
2626

code/20-executors/primes/proc_pool.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ def main() -> None:
3232
executor = futures.ProcessPoolExecutor(workers) # <4>
3333
actual_workers = executor._max_workers # type: ignore # <5>
3434

35-
print(f'Checking {len(NUMBERS)} numbers with {actual_workers} processes:')
35+
print(f'Checking {len(NUMBERS)} numbers',
36+
f'with {actual_workers} processes:')
3637

3738
t0 = perf_counter()
3839

online/cap20.adoc

Lines changed: 472 additions & 217 deletions
Large diffs are not rendered by default.

vol3/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ e faço as demais tarefas nestas cópias especiais para impressão.
1010
| 17| 18| 19| 20| 21| 22| 23| 24| local | tarefa |
1111
|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|-------|-------|
1212
|||||||||`/online`|encurtar links externos|
13-
|||| | | | | |`/online`|revisar estilo|
13+
|||| | | | | |`/online`|revisar estilo|
1414
| | | | | | | | |`/online`|revisar ortografia e gramática|
1515
| | | | | | | | |`/vol3`| refazer referências entre volumes|
1616
| | | | | | | | |`/vol3`| encurtar links entre volumes |

0 commit comments

Comments
 (0)