Skip to content

Instantly share code, notes, and snippets.

View unbit's full-sized avatar

Unbit unbit

View GitHub Profile
@unbit
unbit / gist:8851079
Created February 6, 2014 19:35
embedded pypy
rpython_startup_code();
pypy_setup_home("/root/pypy/pypy",0);
pypy_execute_source(
"import cffi\n"
"ffi = cffi.FFI()\n"
"ffi.cdef('void (*callback)(long);')\n"
"lib = ffi.verify('void (*callback)(long);')\n"
"def callback(i):\n"
" print('x')\n"
@unbit
unbit / gist:8000664
Created December 17, 2013 05:56
Perl spooler
use Data::Dumper;
RETRY=-1;
OK=-2;
IGNORE=0;
uwsgi::spooler(sub {
my $env = shift;
print Dumper($env);
return OK;
@unbit
unbit / gist:7021093
Created October 17, 2013 08:18
persistent/pipelined uwsgi test
use Net::uwsgi;
use IO::Socket::INET;
my $pkt = uwsgi_pkt(0, 0, {'PATH_INFO' => 'foobar', 'test' => 'test001'});
my $socket = IO::Socket::INET->new(PeerAddr => '192.168.173.55:4040');
$socket->send($pkt);
$socket->send($pkt);
$socket->send($pkt);
; run it as uwsgi --ini emperor.ini:emperor
[emperor]
emperor = vassals17
vassals-include = %p
[uwsgi]
logto = /tmp/%(app).log
@unbit
unbit / gist:6680483
Last active December 23, 2015 19:09
grouping apps with uWSGI legions
;app1
[uwsgi]
socket = zzz
wsgi-file = www
myip = 192.168.0.1
; myself
legion = group001 %(myip):5050 99 bf-cbc:secret01
; scroll
legion-scroll = group001 www.unbit.it
; other members
@unbit
unbit / gist:5645131
Created May 24, 2013 17:30
pypy thread patche
diff -r 13938246ac64 -r 615a0acdb06b pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py Fri May 24 13:36:53 2013 +0200
+++ b/pypy/goal/targetpypystandalone.py Fri May 24 15:07:20 2013 +0200
@@ -124,14 +124,21 @@
@entrypoint('main', [], c_name='pypy_init_threads')
def pypy_init_threads():
- if space.config.objspace.usemodules.thread:
- os_thread.setup_threads(space)
- rffi.aroundstate.before()
@unbit
unbit / gist:5635181
Created May 23, 2013 10:32
uWSGi test commands
Report memory usage after each request (app loaded before fork):
uwsgi --http-socket :9090 --pypy-home /opt/pypy --memory-report --master --processes 4 --pypy-wsgi werkzeug.testapp:test_app
Report memory usage after each request (app loaded after fork):
uwsgi --http-socket :9090 --pypy-home /opt/pypy --lazy-apps --memory-report --master --processes 4 --pypy-wsgi werkzeug.testapp:test_app
Enable KSM
@unbit
unbit / gist:5605256
Created May 18, 2013 17:47
better thread attach
diff -r 5e25ae4de748 pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py Sat May 18 13:31:35 2013 +0200
+++ b/pypy/goal/targetpypystandalone.py Sat May 18 19:46:43 2013 +0200
@@ -129,7 +129,12 @@
@entrypoint('main', [], c_name='pypy_thread_attach')
def pypy_thread_attach():
+ os_thread.setup_threads(space)
+ os_thread.bootstrapper.acquire(space, None, None)
rthread.gc_thread_start()
@unbit
unbit / gist:5604066
Created May 18, 2013 11:03
pypy new funcs for uWSGI
diff -r 32dd588a5e23 pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py Fri May 17 16:41:25 2013 -0700
+++ b/pypy/goal/targetpypystandalone.py Sat May 18 13:03:29 2013 +0200
@@ -10,6 +10,8 @@
from rpython.config.config import ConflictConfigError
from pypy.tool.option import make_objspace
from pypy.conftest import pypydir
+from rpython.rlib import rthread
+from pypy.module.thread import os_thread
@unbit
unbit / multisocket.ini
Created April 24, 2013 05:49
using different socket, different protocol on different uWSGI workers
[uwsgi]
; create the socket 0 (uwsgi protocol)
socket = 127.0.0.1:3031
; create the socket 1 (HTTP protocol)
http-socket = 127.0.0.1:8080
; spawn the master
master = true
; spawn 4 processes
processes = 4