Skip to content

Instantly share code, notes, and snippets.

View zhoufankai's full-sized avatar
🎯
Focusing

Blaise zhoufankai

🎯
Focusing
View GitHub Profile
@tokibito
tokibito / test_sendfds.py
Created December 14, 2016 15:23
from multiprocessing.reduction import sendfds, recvfds
import socket
import time
import os
import sys
import tempfile
from multiprocessing.reduction import sendfds, recvfds
import unittest
from unittest import TestCase
@bdarnell
bdarnell / fdserver.py
Created July 9, 2011 20:41
Demonstration of sharing file descriptors across processes
#!/usr/bin/env python
"""This is a demonstration of sharing file descriptors across processes.
It uses Tornado (need a recent post-2.0 version from github) and the
multiprocessing module (from python 2.6+). To run it, start one copy
of fdserver.py and one or more copies of testserver.py (in different
terminals, or backgrounded, etc). Fetch http://localhost:8000 and
you'll see the requests getting answered by different processes (it's
normal for several requests to go to the same process under light
load, but under heavier load it tends to even out).