Skip to content

Instantly share code, notes, and snippets.

View amireldor's full-sized avatar
🦕

Amir Eldor amireldor

🦕
View GitHub Profile
@amireldor
amireldor / pony_orm_bug.py
Created September 9, 2018 23:55
I have some bug with pony ORM, I'll file a new issue I think
# I have a problem with this code with Python 3.6.5, pony 0.7.6
# An exception is thrown:
# "pony.orm.core.TransactionError: db_session is required when working with the database"
# in the "I shall feed thee!" line.
# also see https://github.com/ponyorm/pony/issues/126
import asyncio
from pony.orm import commit, db_session, select, Database, Required
db = Database()
@amireldor
amireldor / fixed_async_funcs.py
Created March 1, 2016 21:27
How to make sure you run the same number of function asynchronically, adding a new one when an old one finishes.
import concurrent.futures
from concurrent.futures import FIRST_COMPLETED, ALL_COMPLETED
import time
from random import random
def do_magic(title):
time.sleep(random() * 3)
print("Bye", title)
WHAT IS GITHUB . com