Skip to content

Instantly share code, notes, and snippets.

View AndreiPashkin's full-sized avatar

Andrew Pashkin AndreiPashkin

  • Warsaw
  • 03:00 (UTC -12:00)
View GitHub Profile
@AndreiPashkin
AndreiPashkin / sqlalchemy_example.py
Created February 14, 2021 15:39 — forked from ronreiter/sqlalchemy_example.py
SQLAlchemy Example
from sqlalchemy import Column, Integer, String, ForeignKey, create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship, backref, sessionmaker, joinedload
# For this example we will use an in-memory sqlite DB.
# Let's also configure it to echo everything it does to the screen.
engine = create_engine('sqlite:///:memory:', echo=True)
# The base class which our objects will be defined on.
Base = declarative_base()
@AndreiPashkin
AndreiPashkin / grace_stop.py
Last active July 8, 2019 17:47 — forked from worldmind/grace_stop.py
Multiprocessing graceful stop
import time
import multiprocessing as mp
import queue as queuelib
N_PROCESSES = 4
def worker(queue: mp.Queue, stop: mp.Event):
print(f"Start job: {mp.current_process().name}")