mirror of https://github.com/scrapy/scrapy.git
Replace prints with logging.
This commit is contained in:
parent
4c7d6bff59
commit
05c085ba9a
|
|
@ -1,9 +1,12 @@
|
|||
import logging
|
||||
import sys
|
||||
|
||||
import scrapy
|
||||
from scrapy.crawler import AsyncCrawlerProcess
|
||||
from scrapy.utils.reactorless import ReactorImportHook
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def hook_count() -> int:
|
||||
return sum(1 for finder in sys.meta_path if isinstance(finder, ReactorImportHook))
|
||||
|
|
@ -23,4 +26,4 @@ for _ in range(2):
|
|||
process.crawl(NoRequestsSpider)
|
||||
process.start()
|
||||
|
||||
print(f"Hooks after runs: {hook_count()}", file=sys.stderr)
|
||||
logger.info(f"Hooks after runs: {hook_count()}")
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
import logging
|
||||
import sys
|
||||
|
||||
import scrapy
|
||||
from scrapy.crawler import AsyncCrawlerProcess
|
||||
from scrapy.utils.reactorless import ReactorImportHook
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class NoRequestsSpider(scrapy.Spider):
|
||||
name = "no_request"
|
||||
|
|
@ -19,8 +22,8 @@ process.crawl(NoRequestsSpider)
|
|||
process.start()
|
||||
|
||||
hook_count = sum(1 for finder in sys.meta_path if isinstance(finder, ReactorImportHook))
|
||||
print(f"Hooks in sys.meta_path after start(): {hook_count}", file=sys.stderr)
|
||||
logger.info(f"Hooks in sys.meta_path after start(): {hook_count}")
|
||||
|
||||
import twisted.internet.reactor # noqa: E402,F401,TID253
|
||||
|
||||
print("Reactor imported after start()", file=sys.stderr)
|
||||
logger.info("Reactor imported after start()")
|
||||
|
|
|
|||
Loading…
Reference in New Issue