This patch has never been submitted upstream for some reason, but it simply
increases the default number of file descriptors the Python process can have on
Cygwin, which mitigates some issues; see
https://cygwin.com/ml/cygwin/2011-03/msg00651.html
diff --git a/Python-3.6.1/Modules/selectmodule.c.orig b/Python-3.6.1/Modules/selectmodule.c
index 47da493..ae60234 100644
--- a/Modules/selectmodule.c
+++ b/Modules/selectmodule.c
@@ -8,6 +8,21 @@
 #define _GNU_SOURCE
 #endif
 
+/* Windows #defines FD_SETSIZE to 64 if FD_SETSIZE isn't already defined.
+   64 is too small (too many people have bumped into that limit).
+   Here we boost it.
+
+   Cygwin also defines FD_SETSIZE to 64, so also increase the limit on
+   Cygwin.  We must do this before sys/types.h is included, which otherwise
+   sets FD_SETSIZE to the default.
+
+   Users who want even more than the boosted limit should #define
+   FD_SETSIZE higher before this; e.g., via compiler /D switch.
+*/
+#if (defined(MS_WINDOWS) || defined(__CYGWIN__)) && !defined(FD_SETSIZE)
+#define FD_SETSIZE 512
+#endif
+
 #include "Python.h"
 #include <structmember.h>
 
@@ -26,16 +41,6 @@
 #undef HAVE_BROKEN_POLL
 #endif
 
-/* Windows #defines FD_SETSIZE to 64 if FD_SETSIZE isn't already defined.
-   64 is too small (too many people have bumped into that limit).
-   Here we boost it.
-   Users who want even more than the boosted limit should #define
-   FD_SETSIZE higher before this; e.g., via compiler /D switch.
-*/
-#if defined(MS_WINDOWS) && !defined(FD_SETSIZE)
-#define FD_SETSIZE 512
-#endif
-
 #if defined(HAVE_POLL_H)
 #include <poll.h>
 #elif defined(HAVE_SYS_POLL_H)
