Skip to content

Instantly share code, notes, and snippets.

View squeaky-pl's full-sized avatar

Paweł Piotr Przeradowski squeaky-pl

View GitHub Profile
In [24]: from sqlalchemy.sql.expression import delete
In [26]: delete(User).where(User.id == 4)
Out[26]: <sqlalchemy.sql.dml.Delete object at 0x7f4b8f7f1b00>
In [28]: s = delete(User).where(User.id == 4)
In [32]: c = s.compile(dialect=dialect)
In [33]: str(c)
In [1]: from sqlalchemy.ext.declarative import declarative_base
In [2]: Base = declarative_base()
In [3]: from sqlalchemy import Column, Integer, String
In [4]: class User(Base):
...: __tablename__ = 'users'
...: id = Column(Integer, primary_key=True)
...: name = Column(String)
File "/src/pypy/rpython/tool/algo/graphlib.py", line 100, in visit
visit(edge.target)
File "/src/pypy/rpython/tool/algo/graphlib.py", line 100, in visit
visit(edge.target)
File "/src/pypy/rpython/tool/algo/graphlib.py", line 100, in visit
visit(edge.target)
File "/src/pypy/rpython/tool/algo/graphlib.py", line 100, in visit
visit(edge.target)
File "/src/pypy/rpython/tool/algo/graphlib.py", line 100, in visit
visit(edge.target)
import asyncio as aio
import signal
import os
from functools import partial
from datetime import datetime, timedelta
initial_alerts = {
1: datetime(2015, 12, 12, 12, 13, 4),
2: datetime(2015, 8, 16, 12, 14, 5)
import asyncio as aio
import signal
import os
from functools import partial
from datetime import datetime, timedelta
initial_alerts = {
1: datetime(2015, 12, 12, 12, 13, 4),
2: datetime(2015, 8, 16, 12, 14, 5)
import asyncio as aio
import signal
import os
from datetime import datetime, timedelta
alerts = {
1: datetime(2015, 12, 12, 11, 57, 4),
2: datetime(2015, 8, 16, 11, 58, 5)
}
"""SQLAlchemy session integration for asyncio.
This is hazardous and fragile material. Please don't make changes here unless
you really know what you are doing. You need to understand how threads work
and why SQLAlchemy does not work with asyncio out of the box.
For the reference consult following articles:
http://docs.sqlalchemy.org/en/latest/orm/contextual.html#thread-local-scope
https://docs.python.org/3/library/asyncio-eventloop.html#executor
https://docs.python.org/3/library/concurrent.futures.html#threadpoolexecutor
PyPy3 nightly server & client
-----------------------------
1KiB
pypy3 client.py --num 10000 --workers 10 --msize 1000
will connect to: ('127.0.0.1', 25000)
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
@squeaky-pl
squeaky-pl / client.py
Last active May 22, 2016 10:17
PyPy + asyncio benchmarks from uvloop project
# Copied with minimal modifications from curio
# https://github.com/dabeaz/curio
from concurrent.futures import ProcessPoolExecutor
import argparse
from socket import *
import time
import sys
LD_LIBRARY_PATH=pypy-c-jit-84568-d463dd98e6a6-linux64/bin virtualenv --clear -p pypy-c-jit-84568-d463dd98e6a6-linux64/bin/pypy3 venv-pypy3
Running virtualenv with interpreter pypy-c-jit-84568-d463dd98e6a6-linux64/bin/pypy3
Deleting tree /home/squeaky/Downloads/venv-pypy3
Not deleting /home/squeaky/Downloads/venv-pypy3/bin
Using base prefix '/home/squeaky/Downloads/pypy-c-jit-84568-d463dd98e6a6-linux64'
New pypy executable in /home/squeaky/Downloads/venv-pypy3/bin/pypy3
Also creating executable in /home/squeaky/Downloads/venv-pypy3/bin/pypy
Installing setuptools, pip, wheel...
Complete output from command /home/squeaky/Downloads/venv-pypy3/bin/pypy3 - setuptools pip wheel:
Collecting setuptools