in_httpを作りたい。
処理の流れを追ってみる。
AddPluginでファクトリを登録する。 ikはファクトリのNewを呼び出してプラグインを生成する。 このNewでik本体と設定が渡される。
def verify(message): | |
# the string to sign | |
sign_str = [] | |
for key in ("Message", "MessageId", "Subject", "Timestamp", "TopicArn", "Type"): | |
if key == "Subject" and key not in message: | |
continue | |
sign_str.append(key) | |
sign_str.append(message[key]) | |
sign_str.append("") | |
sign_str = "¥n".join(sign_str) |
http { | |
include /etc/nginx/mime.types; | |
default_type application/octet-stream; | |
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | |
'$status $body_bytes_sent "$http_referer" ' | |
'"$http_user_agent" "$request_time"'; | |
sendfile on; | |
keepalive_timeout 65; |
from google.appengine.ext import db | |
class Foo(db.Model): | |
pass | |
class Bar(db.Model): | |
foo = db.ReferenceProperty(Foo) | |
Bar.foo.get_value_for_datastore(bar_obj) #=> Key of Foo |
class QueryIterator(object): | |
def __init__(self, query, limit=None): | |
self.limit = limit | |
self.count = 0 | |
if limit: | |
config = datastore_query.QueryOptions(limit=limit, prefetch_size=limit) | |
else: | |
config = None | |
self.iterator = query.run(config=config) |
import struct, base64 | |
def long_to_str(value): | |
value = struct.pack('q', value) | |
value = base64.urlsafe_b64encode(value) | |
value = value.rstrip('=') | |
value = value.rstrip('A') | |
return value | |
# -*- coding: utf-8 -*- | |
import urllib | |
import urllib2 | |
import time | |
MASTER_SERVER = '127.0.0.1' | |
PAGE_FORMAT = 'http://%s/mediawiki/index.php/%s' | |
TARGETS = [ |
## 課題 | |
現在の実装では、送信 `f.conn.Write` の間はロックを獲得しているので、バッファ `pending` への書き込みをブロックする。ネットワークの送信は時間がかかるので、書き込みのパフォーマンスも出ない。 | |
## 対策 | |
Write ではロックを獲得しないようにする。 | |
Write の前に送信するバッファを取得し、書き込み側が違うバッファを使うように差し替える。 | |
また、Write 自体も別のgoroutineで実施する(そうでないと、ロックを回避したのに結局ブロックする)。 |
# -*- coding: utf-8 -*- | |
import os | |
import datetime | |
import jinja2 | |
import webapp2 | |
from google.appengine.api import users | |
from google.appengine.ext import ndb | |
class Page(ndb.Model): | |
title = ndb.StringProperty(indexed=False) |