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 | |
| import random | |
| async def do_it(n): | |
| if random.random() < 0.1: | |
| raise Exception('Failed test') | |
| await asyncio.sleep(random.uniform(0.5, 2)) | |
| return n |
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
| """ | |
| Just run: | |
| python3 custom-pipe-example.py | |
| """ | |
| import subprocess | |
| import os | |
| import json | |
| import time | |
| import sys | |
| from pprint import pprint |
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
| """ | |
| Start process with different options | |
| - detached | |
| - with new console | |
| - with custom envs | |
| Example: | |
| # python start_process.py --new-console --env PYTHONPATH=/my/path python myscript.py | |
| """ | |
| import subprocess | |
| import os |
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
| services: | |
| zookeeper: | |
| image: confluentinc/cp-zookeeper:latest | |
| container_name: zookeeper | |
| environment: | |
| ZOOKEEPER_CLIENT_PORT: 2181 | |
| ZOOKEEPER_TICK_TIME: 2000 | |
| ports: | |
| - "2181:2181" |
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 contextlib import asynccontextmanager | |
| from typing import Any, Optional | |
| from fastapi import FastAPI, HTTPException, Depends | |
| from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine | |
| from sqlalchemy.orm import sessionmaker, selectinload, Mapped, mapped_column, relationship, declarative_base | |
| from sqlalchemy import ForeignKey, JSON, select | |
| from sqlalchemy.types import Enum | |
| from pydantic import BaseModel | |
| import enum |
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 json | |
| import os | |
| import time | |
| import orjson | |
| import ujson | |
| file = 'data.json' | |
| with open(file, 'r') as f: | |
| file_data = f.read() | |
| data = json.loads(file_data) |
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 fastapi import FastAPI, APIRouter, Depends, HTTPException, status | |
| from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine | |
| from sqlalchemy.ext.asyncio import async_sessionmaker | |
| from sqlalchemy import String | |
| from sqlalchemy.ext.declarative import declarative_base | |
| from sqlalchemy.future import select | |
| from sqlalchemy.orm import mapped_column, Mapped | |
| from typing import TypeVar, Generic, Annotated, List | |
| from contextlib import asynccontextmanager | |
| from pydantic import BaseModel, ConfigDict |
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
| """ | |
| Requirements | |
| python = "^3.11" | |
| uvicorn = "^0.32.0" | |
| SQLAlchemy = "^2.0.36" | |
| asyncpg = "^0.30.0" | |
| fastapi = "^0.115.4" | |
| """ |
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 hou | |
| class Connector: | |
| container_node_type = "" | |
| input_node_type = "" | |
| input_connector_name = "" | |
| def __init__(self, out_node): | |
| self.out_node = out_node |
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 List, Optional | |
| import aiosqlite | |
| from fastapi import FastAPI, HTTPException, Depends | |
| from sqlalchemy import Column, Integer, String, Table, ForeignKey, select, UniqueConstraint | |
| from sqlalchemy.ext.declarative import declarative_base | |
| from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession, async_scoped_session, async_sessionmaker | |
| from sqlalchemy.orm import relationship, mapped_column, Mapped, backref, DeclarativeBase, selectinload | |
| from pydantic import BaseModel as BaseSchema, ConfigDict | |
| from contextlib import asynccontextmanager |
NewerOlder