mirror of https://github.com/scrapy/scrapy.git
prevent 'import scrapy' from failing when twisted module is not available, also moved twisted 2.5.0 monkeypatch into a more specific module name
This commit is contained in:
parent
c4f77c4da0
commit
bf55a4708f
|
|
@ -13,8 +13,7 @@ if sys.version_info < (2,5):
|
|||
sys.exit(1)
|
||||
|
||||
# monkey patches to fix external library issues
|
||||
from scrapy.xlib.patches import apply_patches
|
||||
apply_patches()
|
||||
from scrapy.xlib import twisted_250_monkeypatches
|
||||
|
||||
# optional_features is a set containing Scrapy optional features
|
||||
optional_features = set()
|
||||
|
|
|
|||
|
|
@ -1,13 +1,9 @@
|
|||
"""
|
||||
Monkey patches for supporting Twisted 2.5.0
|
||||
|
||||
NOTE: This module must not fail if twisted module is not available.
|
||||
"""
|
||||
|
||||
import twisted
|
||||
|
||||
def apply_patches():
|
||||
if twisted.__version__ < '8.0.0':
|
||||
add_missing_blockingCallFromThread()
|
||||
|
||||
# This function comes bundled with Twisted 8.x and above
|
||||
def add_missing_blockingCallFromThread():
|
||||
import Queue
|
||||
|
|
@ -42,3 +38,11 @@ def add_missing_blockingCallFromThread():
|
|||
|
||||
from twisted.internet import threads
|
||||
threads.blockingCallFromThread = blockingCallFromThread
|
||||
|
||||
try:
|
||||
import twisted
|
||||
if twisted.__version__ < '8.0.0':
|
||||
add_missing_blockingCallFromThread()
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue