Avoid setting open file limits on Windows OS.

Python resource module is unavailable on Windows OS.
This commit is contained in:
Abhinav Singh 2018-12-14 18:44:56 +05:30
parent 83b86426b3
commit c7e47cc7e7
2 changed files with 15 additions and 5 deletions

View File

@ -9,8 +9,9 @@ Features
- Distributed as a single file module
- No external dependency other than standard Python library
- Support for `http`, `https` and `websockets` request proxy
- Basic authentication support
- Optimize for large file uploads and downloads
- IPv4 and IPv6 support
- Basic authentication support
Install
-------

View File

@ -9,6 +9,7 @@
:copyright: (c) 2013-2018 by Abhinav Singh.
:license: BSD, see LICENSE for more details.
"""
import os
import sys
import errno
import base64
@ -17,9 +18,11 @@ import select
import logging
import argparse
import datetime
import resource
import threading
if os.name != 'nt':
import resource
VERSION = (0, 3)
__version__ = '.'.join(map(str, VERSION[0:2]))
__description__ = 'HTTP Proxy Server in Python'
@ -43,7 +46,9 @@ else: # pragma: no cover
def text_(s, encoding='utf-8', errors='strict'): # pragma: no cover
""" If ``s`` is an instance of ``binary_type``, return
"""Utility to ensure text-like usability.
If ``s`` is an instance of ``binary_type``, return
``s.decode(encoding, errors)``, otherwise return ``s``"""
if isinstance(s, binary_type):
return s.decode(encoding, errors)
@ -51,7 +56,9 @@ def text_(s, encoding='utf-8', errors='strict'): # pragma: no cover
def bytes_(s, encoding='utf-8', errors='strict'): # pragma: no cover
""" If ``s`` is an instance of ``text_type``, return
"""Utility to ensure binary-like usability.
If ``s`` is an instance of ``text_type``, return
``s.encode(encoding, errors)``, otherwise return ``s``"""
if isinstance(s, text_type):
return s.encode(encoding, errors)
@ -668,6 +675,8 @@ def main():
format='%(asctime)s - %(levelname)s - %(funcName)s:%(lineno)d - %(message)s')
try:
# resource module is not available on Windows OS
if os.name != 'nt':
set_open_file_limit(int(args.open_file_limit))
auth_code = None