Skip to content

Instantly share code, notes, and snippets.

@Lothiraldan
Lothiraldan / Output
Last active December 29, 2015 05:59
Tornado + yield from = <3
# http://localhost:8888/?mode=sync
http://wikipedia.com code: 200
http://google.com code: 200
http://example.com code: 200
#> time curl http://localhost:8888/\?mode\=sync
http://wikipedia.com code: 200<br/>http://google.com code: 200<br/>http://example.com code: 200curl http://localhost:8888/\?mode\=sync 0,01s user 0,00s system 0% cpu 1,106 total
# http://localhost:8888/?mode=async
import sys
import socket
from tornado.web import Application as BaseApplication
from tornado.options import define, options, parse_command_line
class Application(BaseApplication):
def listen(self, port, address="", **kwargs):
if options.fd:
@Lothiraldan
Lothiraldan / gist:5612446
Created May 20, 2013 14:05
Fix for circus #403
diff --git a/circus/process.py b/circus/process.py
index 070cb10..f7cb699 100644
--- a/circus/process.py
+++ b/circus/process.py
@@ -124,7 +124,7 @@ class Process(object):
if self.uid:
os.setuid(self.uid)
- self._worker = Popen(args, cwd=self.working_dir,
+ self._worker = Popen(args, bufsize=-1, cwd=self.working_dir,
diff --git a/circus/process.py b/circus/process.py
index 070cb10..f7cb699 100644
--- a/circus/process.py
+++ b/circus/process.py
@@ -124,7 +124,7 @@ class Process(object):
if self.uid:
os.setuid(self.uid)
- self._worker = Popen(args, cwd=self.working_dir,
+ self._worker = Popen(args, bufsize=-1, cwd=self.working_dir,
@Lothiraldan
Lothiraldan / direct_call.sh
Created May 18, 2013 14:16
Hello world benchmark.
&> python hello_tornado.py &
&> boom http://localhost:8888 -c 100 -n 1000
Server Software: TornadoServer/3.0.1
Running GET http://127.0.0.1:8888
Host: localhost
Running 1000 times per 100 workers.
Starting the load [======================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
@Lothiraldan
Lothiraldan / circus.ini
Created May 18, 2013 14:15
Hello world tornado, circus config
[circus]
check_delay = 5
endpoint = tcp://127.0.0.1:5555
pubsub_endpoint = tcp://127.0.0.1:5556
stats_endpoint = tcp://127.0.0.1:5557
httpd = True
httpd_host = localhost
httpd_port = 8080
[watcher:dummy]
@Lothiraldan
Lothiraldan / hello_world_circus.py
Created May 18, 2013 14:12
Hello world tornado working with circus
import sys
import socket
import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")
application = tornado.web.Application([
@Lothiraldan
Lothiraldan / hello_world.py
Created May 18, 2013 14:11
Tornado hello world
import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")
application = tornado.web.Application([
(r"/", MainHandler),
])
@Lothiraldan
Lothiraldan / expected_output_0.20.6
Last active December 16, 2015 19:59
Timing issue with aliases and index status
{"ok":true,"acknowledged":true}{"ok":true,"acknowledged":true}{"ok":true,"acknowledged":true}
[u'test.1.1']
[u'test.1.1']
{"ok":true,"acknowledged":true}{"ok":true,"acknowledged":true}{"ok":true,"acknowledged":true}
[u'test.1.2']
[u'test.1.2']
{"ok":true,"acknowledged":true}%
@Lothiraldan
Lothiraldan / app.py
Created April 9, 2013 09:27
How to make gunicorn timeout with a simple app?
import requests
from flask import Flask
app = Flask(__name__)
app.debug=True
@app.route("/hello")
def world():
return "Hello world"
@app.route("/")