This file contains hidden or 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
# aproducer.py | |
# | |
# Async Producer-consumer problem. | |
# Challenge: How to implement the same functionality, but no threads. | |
import time | |
from collections import deque | |
import heapq | |
class Scheduler: |
This file contains hidden or 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
import sys,os | |
import curses | |
def draw_menu(stdscr): | |
k = 0 | |
cursor_x = 0 | |
cursor_y = 0 | |
# Clear and refresh the screen for a blank canvas | |
stdscr.clear() |
This file contains hidden or 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
from typing import ( | |
TypeVar, | |
Type, | |
Optional, | |
List, | |
Any, | |
Callable | |
) | |
import dataclasses | |
import inspect |
This file contains hidden or 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
import java.time.format.DateTimeFormatter; | |
import java.time.Instant; | |
import java.time.ZonedDateTime; | |
import java.time.ZoneId; | |
import java.time.ZoneOffset; | |
Instant.now(); | |
// java.time.Instant = 2015-08-13T09:28:27.141Z | |
DateTimeFormatter.ISO_INSTANT.format(Instant.now()); |
This file contains hidden or 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
xn--80aejlkhkvigj4jej.xn--p1ai |
This file contains hidden or 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
async with aiohttp.ClientSession() as session: | |
async with session.get('https://api.github.com/events') as resp: | |
print(resp.status) | |
print(await resp.text()) |
This file contains hidden or 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
Деплой fab -f import_api.py -H analytic,process5 deploy_update | |
Описалово и рекомендации: практически не было случаев чтобы сервис падал с ошибкой, но бывает что публикации не верно форматируются | |
или и вовсе не разбираются. Форматирование публикации задается в ModelAttrVisitor и реализациях. Для каждого информ. агенства | |
есть своя реализация visitor. Обработка amqp сообщения происходит в BaseImportConsumerHandler и реализациях. Для каждого | |
информ. агенства есть своя реализация handler. Реализация занимается преобразованием форматов (doc в docx и т.д), хранит парсер | |
и запускает у парсер метод parse. FactivaConsumerHandler хранит еще и конкретный посетитель и наверное это правильно - если хочешь, | |
можешь переносить посетители из парсеров в хендлеры. Если для информ. агенств импортируются документы, парсеры принимаю на вход | |
высокоуровнивые обертки: docx.api.Document для docx и очopenpyxl.workbook.workbook.Workbook для xlsx. Типичный парсер разбирает | |
импортируемый документ и генерирует модели News и Source, аггреги |
This file contains hidden or 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
{ | |
"author": null, | |
"created": "2016-08-02T02:30:00", | |
"id": "a7782476ac2a82683f5416cfb7a8639f14452439", | |
"image": [], | |
"source": { | |
"id": "53210662198c7e66ffe19eca08c649575cb54bd6", | |
"level_name": null, | |
"logo": null, | |
"name": "PrimMarketing.ru", |
This file contains hidden or 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
_id = r'[a-zA-Z0-9-_]+' | |
# @formatter:off | |
# URLs удобнее читать без форматирования по PEP | |
ENDPOINTS = ( | |
endpoint(r"/", MainRequestHandler), # + | |
endpoint(r"/_configuration", ConfRequestHandler), # + | |
endpoint(r"/report", r.ReportRequestHandler), # +- | |
endpoint(r"/report".format(_id), r.ReportRequestHandler), # +- | |
endpoint(r"/report/(?P<report_id>{})".format(_id), r.ReportRequestHandler), # +- |
This file contains hidden or 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
import asyncio | |
def call_periodic(interval, callback, *args, **kwargs): | |
# get loop as a kwarg or take the default one | |
loop = kwargs.get('loop') or asyncio.get_event_loop() | |
# record the loop's time when call_periodic was called | |
start = loop.time() | |
def run(handle): |
NewerOlder