Removed (very old and possibly broken) backwards compatibility support for Twisted 2.5

This commit is contained in:
Pablo Hoffman 2012-03-15 00:28:13 -03:00
parent 9fddc73ed8
commit b6ae266546
4 changed files with 3 additions and 52 deletions

View File

@ -13,7 +13,7 @@ Requirements
* `Python`_ 2.6, 2.7 (3.x is not yet supported)
* `Twisted`_ 2.5.0, 8.0 or above (Windows users: you'll need to install
* `Twisted`_ 8.0 or above (Windows users: you'll need to install
`Zope.Interface`_ and maybe `pywin32`_ because of `this Twisted bug`_)
* `w3lib`_

View File

@ -15,7 +15,7 @@ if sys.version_info < (2,6):
warnings.filterwarnings('ignore', category=DeprecationWarning, module='twisted')
# monkey patches to fix external library issues
from scrapy.xlib import twisted_250_monkeypatches, urlparse_monkeypatches
from scrapy.xlib import urlparse_monkeypatches
# optional_features is a set containing Scrapy optional features
optional_features = set()

View File

@ -1,49 +0,0 @@
"""
Monkey patches for supporting Twisted 2.5.0
NOTE: This module must not fail if twisted module is not available.
"""
# This function comes bundled with Twisted 8.x and above
def add_missing_blockingCallFromThread():
import Queue
from twisted.internet import defer
from twisted.python import failure
def blockingCallFromThread(reactor, f, *a, **kw):
"""
Run a function in the reactor from a thread, and wait for the result
synchronously, i.e. until the callback chain returned by the function
get a result.
@param reactor: The L{IReactorThreads} provider which will be used to
schedule the function call.
@param f: the callable to run in the reactor thread
@type f: any callable.
@param a: the arguments to pass to C{f}.
@param kw: the keyword arguments to pass to C{f}.
@return: the result of the callback chain.
@raise: any error raised during the callback chain.
"""
queue = Queue.Queue()
def _callFromThread():
result = defer.maybeDeferred(f, *a, **kw)
result.addBoth(queue.put)
reactor.callFromThread(_callFromThread)
result = queue.get()
if isinstance(result, failure.Failure):
result.raiseException()
return result
from twisted.internet import threads
threads.blockingCallFromThread = blockingCallFromThread
try:
import twisted
from twisted.python.versions import Version
if twisted.version < Version("twisted", 8, 0, 0):
add_missing_blockingCallFromThread()
except ImportError:
pass

View File

@ -120,7 +120,7 @@ try:
except ImportError:
from distutils.core import setup
else:
setup_args['install_requires'] = ['Twisted>=2.5', 'w3lib>=1.1', 'pyOpenSSL']
setup_args['install_requires'] = ['Twisted>=8.0', 'w3lib>=1.1', 'pyOpenSSL']
if sys.version_info < (2, 6):
setup_args['install_requires'] += ['simplejson']
try: