Skip to content

Instantly share code, notes, and snippets.

@rougeth
Created April 21, 2018 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rougeth/ae171c106be46791233fbb17ec6a61de to your computer and use it in GitHub Desktop.
Save rougeth/ae171c106be46791233fbb17ec6a61de to your computer and use it in GitHub Desktop.
Async que se faz - TDC 2018
# Código usado na palestra "Async que se faz - asyncio na prática"
# no TDC 2018 em Florianópolis
# Creative Commons Attribution 4.0 International license <https://creativecommons.org/licenses/by/4.0/>
import random
from time import sleep
from utils import UPDATE_AVG, sync_request
def buscar_pedidos_no_banco():
print('- Buscar pedidos no banco')
return range(18000)
def checar_pedido_no_correios(pedido):
sync_request(pedido, 'Correios')
def atualizar_pacote_no_banco(pedido):
print('- {}: Atualiza pacote'.format(pedido))
def notificar_usuario(pedido):
sync_request(pedido, 'Telegram')
def main():
pedidos = buscar_pedidos_no_banco()
for pedido in pedidos:
checar_pedido_no_correios(pedido)
if random.choice(UPDATE_AVG):
atualizar_pacote_no_banco(pedido)
notificar_usuario(pedido)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment