HDEラボの桜井です。 昨日のプログラムに、ちょっとだけ機能を追加してみましょう。 追加する機能は、プロキシサーバよりさらに先にあるプロキシサーバ(上位プロキシ)を 経由してインターネットにつなげるものです。 # -*- coding: utf-8 -*- from twisted.web import http, proxy from twisted.internet import reactor, ssl from twisted.python import log import sys import urlparse # とりあえずログを標準出力へ log.startLogging(sys.stdout) # 上位プロキシ設定 proxyHost = "192.168.0.1" proxyPort = 8080 # プロキシリクエストのクラス class MyProxyRequest
***** ご注意 ***** さくらレンタルサーバ内での常駐プロセスの起動は、さくらレンタルサーバの禁止事項で禁止されています。 本記事のプログラムを試される方は、Twistedサーバプログラムの起動は、一時的にして頂きますようお願い致します。 さくらレンタルサーバにSSHでリモートログインし、以下の手順に従って、Python Twistedをインストール: > bash > mkdir ~/tmp > cd ~/tmp > wget http://twistedmatrix.com/Releases/Twisted/12.0/Twisted-12.0.0.tar.bz2 > tar xvfz Twisted-12.0.0.tar.bz2 > cd Twisted-12.0.0.tar.bz2 > mkdir -p ~/lib/python2.7/site-packages/ > exp
この文書は非同期プログラミングというプログラミング・モデルの紹介と Twisted の Deferred について解説したものです。「イベントの確約された結果」をシンボル化し、その内容をハンドラ関数に渡せるよう抽象化されたものが Deferred です。 この文書は Twisted 初心者向けのものですが、読者は Python のプログラミングに慣れ親しんでおり、サーバやクライアント、ソケットなどネットワークの基礎的な知識があることを前提に書かれています。これを読むことにより、(タスクのインターリーブを実行する)並行プログラミングの概要および Twisted の並行処理手法であるノンブロッキング・コード (non-blocking code) と非同期コード (asynchronous code) について理解できることでしょう。 Deferred を含む並行モデルの解説の後に、Defer
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く