From 6db8f38c3be54fd63c9ee936d3a9a7fd3f156585 Mon Sep 17 00:00:00 2001
From: Zooko O'Whielacronx <zooko@zooko.com>
Date: Wed, 14 Jan 2009 09:15:46 -0700
Subject: [PATCH] setup: use poll reactor for trial if on linux2 or cygwin

---
 setup.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/setup.py b/setup.py
index d5456f7f..11c833f8 100644
--- a/setup.py
+++ b/setup.py
@@ -154,6 +154,15 @@ if 'darcsver' in sys.argv[1:]:
 # setuptools_trial is needed only if you want "./setup.py trial" to execute the tests.
 # http://pypi.python.org/pypi/setuptools_trial
 if 'trial' in sys.argv[1:]:
+    # Cygwin requires the poll reactor to work at all.  Linux requires the poll reactor to avoid
+    # bug #402 (twisted bug #3218).  In general, the poll reactor is better than the select
+    # reactor, but it is not available on all platforms.  According to exarkun on IRC, it is
+    # available but buggy on some versions of Mac OS X, so just because you can install it
+    # doesn't mean we want to use it on every platform.
+    if sys.platform in ("linux2", "cygwin"):
+        for arg in sys.argv:
+            if arg.startswith("--reactor")
+        sys.argv.append("--reactor=poll")
     setup_requires.append('setuptools_trial >= 0.2')
 
 # setuptools_darcs is required to produce complete distributions (such as with
-- 
2.45.2