Skip to content

Instantly share code, notes, and snippets.

View unbit's full-sized avatar

Unbit unbit

View GitHub Profile
@unbit
unbit / openerp.wsgi
Created February 28, 2012 19:21
openerp .wsgi file for uWSGI and mod_wsgi
import openerp
try:
import uwsgi
uwsgi.port_fork_hook = openerp.wsgi.core.on_starting
except:
openerp.wsgi.core.on_starting()
# Equivalent of --load command-line option
openerp.conf.server_wide_modules = ['web']
@unbit
unbit / openerp.wsgi
Created February 28, 2012 19:41
.wsgi file for openerp (second attempt)
import openerp
import uwsgi
def foobar():
print "ciao"
openerp.conf.server_wide_modules = ['web']
openerp.wsgi.core.on_starting(None)
diff -r c245ac034d7c master_utils.c
--- a/master_utils.c Tue May 15 08:59:08 2012 +0200
+++ b/master_utils.c Wed May 16 10:20:52 2012 +0200
@@ -267,6 +267,17 @@
uwsgi_sock = uwsgi_sock->next;
}
+ uwsgi_sock = uwsgi.shared_sockets;
+ while (uwsgi_sock) {
+ if (i == uwsgi_sock->fd) {
diff -r c245ac034d7c plugins/python/python_plugin.c
--- a/plugins/python/python_plugin.c Tue May 15 08:59:08 2012 +0200
+++ b/plugins/python/python_plugin.c Wed May 16 10:21:54 2012 +0200
@@ -249,6 +249,8 @@
void uwsgi_python_atexit() {
+ if (uwsgi.mywid == -1) goto realstuff;
+
// if hijacked do not run atexit hooks
my $app = sub {
my $env = shift;
$env->{'psgi.input'}->read(my $buf, 4096);
print $buf."\n" ;
return [
'200',
[ 'Content-Type' => 'text/html' ],
[ "<h1>Hello World</h1>" ],
];
};
import threading
class AAA(threading.Thread):
def run(self):
while 1:
print "A"
a = AAA()
a.start()
def application(e,s):
pass
@unbit
unbit / testg.py
Last active December 15, 2015 01:09
psygogreen test
import psycopg2
import gevent_psycopg2
gevent_psycopg2.monkey_patch()
def application(e, s):
conn = psycopg2.connect("dbname='foobar' user='postgres'")
print conn
cur = conn.cursor()
@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
@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 / 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()