prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  engine status util references removed engine.slots attribute
  ```
  Traceback (most recent call last): Less
        File "/usr/lib/pymodules/python2.7/scrapy/xlib/pydispatch/robustapply.py", line 54, in robustApply
          return receiver(*arguments, **named)
        File "/usr/lib/pymodules/python2.7/scrapy/contrib/memusage.py", line 63, in engine_started
          tsk.start(60.0, now=True)
        File "/usr/lib/python2.7/dist-packages/twisted/internet/task.py", line 163, in start
          self()
        File "/usr/lib/python2.7/dist-packages/twisted/internet/task.py", line 208, in __call__
          d = defer.maybeDeferred(self.f, *self.a, **self.kw)
      --- <exception caught here> ---
        File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 134, in maybeDeferred
          result = f(*args, **kw)
        File "/usr/lib/pymodules/python2.7/scrapy/contrib/memusage.py", line 103, in _check_warning
          self._send_report(self.notify_mails, subj)
        File "/usr/lib/pymodules/python2.7/scrapy/contrib/memusage.py", line 116, in _send_report
          s += pformat(get_engine_status(self.crawler.engine))
        File "/usr/lib/pymodules/python2.7/scrapy/utils/engine.py", line 33, in get_engine_status
          for spider in engine.slots.keys():
      exceptions.AttributeError: 'ExecutionEngine' object has no attribute 'slots'
  ```
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `scrapy/utils/engine.py`
  Content:
  ```
  1 """Some debugging functions for working with the Scrapy engine"""
  2 
  3 from __future__ import print_function
  4 from time import time # used in global tests code
  5 
  6 def get_engine_status(engine):
  7     """Return a report of the current engine status"""
  8     global_tests = [
  9         "time()-engine.start_time",
  10         "engine.has_capacity()",
  11         "len(engine.downloader.active)",
  12         "engine.scraper.is_idle()",
  13     ]
  14     spider_tests = [
  15         "engine.spider_is_idle(spider)",
  16         "engine.slot.closing",
  17         "len(engine.slot.inprogress)",
  18         "len(engine.slot.scheduler.dqs or [])",
  19         "len(engine.slot.scheduler.mqs)",
  20         "len(engine.scraper.slot.queue)",
  21         "len(engine.scraper.slot.active)",
  22         "engine.scraper.slot.active_size",
  23         "engine.scraper.slot.itemproc_size",
  24         "engine.scraper.slot.needs_backout()",
  25     ]
  26 
  27     status = {'global': [], 'spiders': {}}
  28     for test in global_tests:
  29         try:
  30             status['global'] += [(test, eval(test))]
  31         except Exception as e:
  32             status['global'] += [(test, "%s (exception)" % type(e).__name__)]
  33     for spider in engine.slots.keys():
  34         x = []
  35         for test in spider_tests:
  36             try:
  37                 x += [(test, eval(test))]
  38             except Exception as e:
  39                 x += [(test, "%s (exception)" % type(e).__name__)]
  40             status['spiders'][spider] = x
  41     return status
  42 
  43 def format_engine_status(engine=None):
  44     status = get_engine_status(engine)
  45     s = "Execution engine status\n\n"
  46     for test, result in status['global']:
  47         s += "%-47s : %s\n" % (test, result)
  48     s += "\n"
  49     for spider, tests in status['spiders'].items():
  50         s += "Spider: %s\n" % spider
  51         for test, result in tests:
  52             s += "  %-50s : %s\n" % (test, result)
  53     return s
  54 
  55 def print_engine_status(engine):
  56     print(format_engine_status(engine))
  57 
  58
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/scrapy/utils/engine.py b/scrapy/utils/engine.py
  --- a/scrapy/utils/engine.py
  +++ b/scrapy/utils/engine.py
  @@ -5,14 +5,13 @@
   
   def get_engine_status(engine):
       """Return a report of the current engine status"""
  -    global_tests = [
  +    tests = [
           "time()-engine.start_time",
           "engine.has_capacity()",
           "len(engine.downloader.active)",
           "engine.scraper.is_idle()",
  -    ]
  -    spider_tests = [
  -        "engine.spider_is_idle(spider)",
  +        "engine.spider.name",
  +        "engine.spider_is_idle(engine.spider)",
           "engine.slot.closing",
           "len(engine.slot.inprogress)",
           "len(engine.slot.scheduler.dqs or [])",
  @@ -24,34 +23,23 @@
           "engine.scraper.slot.needs_backout()",
       ]
   
  -    status = {'global': [], 'spiders': {}}
  -    for test in global_tests:
  +    checks = []
  +    for test in tests:
           try:
  -            status['global'] += [(test, eval(test))]
  +            checks += [(test, eval(test))]
           except Exception as e:
  -            status['global'] += [(test, "%s (exception)" % type(e).__name__)]
  -    for spider in engine.slots.keys():
  -        x = []
  -        for test in spider_tests:
  -            try:
  -                x += [(test, eval(test))]
  -            except Exception as e:
  -                x += [(test, "%s (exception)" % type(e).__name__)]
  -            status['spiders'][spider] = x
  -    return status
  +            checks += [(test, "%s (exception)" % type(e).__name__)]
  +
  +    return checks
   
   def format_engine_status(engine=None):
  -    status = get_engine_status(engine)
  +    checks = get_engine_status(engine)
       s = "Execution engine status\n\n"
  -    for test, result in status['global']:
  +    for test, result in checks:
           s += "%-47s : %s\n" % (test, result)
       s += "\n"
  -    for spider, tests in status['spiders'].items():
  -        s += "Spider: %s\n" % spider
  -        for test, result in tests:
  -            s += "  %-50s : %s\n" % (test, result)
  +
       return s
   
   def print_engine_status(engine):
       print(format_engine_status(engine))
  -
  
verification_info: {"golden_diff": "diff --git a/scrapy/utils/engine.py b/scrapy/utils/engine.py\n--- a/scrapy/utils/engine.py\n+++ b/scrapy/utils/engine.py\n@@ -5,14 +5,13 @@\n \n def get_engine_status(engine):\n     \"\"\"Return a report of the current engine status\"\"\"\n-    global_tests = [\n+    tests = [\n         \"time()-engine.start_time\",\n         \"engine.has_capacity()\",\n         \"len(engine.downloader.active)\",\n         \"engine.scraper.is_idle()\",\n-    ]\n-    spider_tests = [\n-        \"engine.spider_is_idle(spider)\",\n+        \"engine.spider.name\",\n+        \"engine.spider_is_idle(engine.spider)\",\n         \"engine.slot.closing\",\n         \"len(engine.slot.inprogress)\",\n         \"len(engine.slot.scheduler.dqs or [])\",\n@@ -24,34 +23,23 @@\n         \"engine.scraper.slot.needs_backout()\",\n     ]\n \n-    status = {'global': [], 'spiders': {}}\n-    for test in global_tests:\n+    checks = []\n+    for test in tests:\n         try:\n-            status['global'] += [(test, eval(test))]\n+            checks += [(test, eval(test))]\n         except Exception as e:\n-            status['global'] += [(test, \"%s (exception)\" % type(e).__name__)]\n-    for spider in engine.slots.keys():\n-        x = []\n-        for test in spider_tests:\n-            try:\n-                x += [(test, eval(test))]\n-            except Exception as e:\n-                x += [(test, \"%s (exception)\" % type(e).__name__)]\n-            status['spiders'][spider] = x\n-    return status\n+            checks += [(test, \"%s (exception)\" % type(e).__name__)]\n+\n+    return checks\n \n def format_engine_status(engine=None):\n-    status = get_engine_status(engine)\n+    checks = get_engine_status(engine)\n     s = \"Execution engine status\\n\\n\"\n-    for test, result in status['global']:\n+    for test, result in checks:\n         s += \"%-47s : %s\\n\" % (test, result)\n     s += \"\\n\"\n-    for spider, tests in status['spiders'].items():\n-        s += \"Spider: %s\\n\" % spider\n-        for test, result in tests:\n-            s += \"  %-50s : %s\\n\" % (test, result)\n+\n     return s\n \n def print_engine_status(engine):\n     print(format_engine_status(engine))\n-\n", "issue": "engine status util references removed engine.slots attribute\n```\nTraceback (most recent call last): Less\n      File \"/usr/lib/pymodules/python2.7/scrapy/xlib/pydispatch/robustapply.py\", line 54, in robustApply\n        return receiver(*arguments, **named)\n      File \"/usr/lib/pymodules/python2.7/scrapy/contrib/memusage.py\", line 63, in engine_started\n        tsk.start(60.0, now=True)\n      File \"/usr/lib/python2.7/dist-packages/twisted/internet/task.py\", line 163, in start\n        self()\n      File \"/usr/lib/python2.7/dist-packages/twisted/internet/task.py\", line 208, in __call__\n        d = defer.maybeDeferred(self.f, *self.a, **self.kw)\n    --- <exception caught here> ---\n      File \"/usr/lib/python2.7/dist-packages/twisted/internet/defer.py\", line 134, in maybeDeferred\n        result = f(*args, **kw)\n      File \"/usr/lib/pymodules/python2.7/scrapy/contrib/memusage.py\", line 103, in _check_warning\n        self._send_report(self.notify_mails, subj)\n      File \"/usr/lib/pymodules/python2.7/scrapy/contrib/memusage.py\", line 116, in _send_report\n        s += pformat(get_engine_status(self.crawler.engine))\n      File \"/usr/lib/pymodules/python2.7/scrapy/utils/engine.py\", line 33, in get_engine_status\n        for spider in engine.slots.keys():\n    exceptions.AttributeError: 'ExecutionEngine' object has no attribute 'slots'\n```\n\n", "before_files": [{"content": "\"\"\"Some debugging functions for working with the Scrapy engine\"\"\"\n\nfrom __future__ import print_function\nfrom time import time # used in global tests code\n\ndef get_engine_status(engine):\n    \"\"\"Return a report of the current engine status\"\"\"\n    global_tests = [\n        \"time()-engine.start_time\",\n        \"engine.has_capacity()\",\n        \"len(engine.downloader.active)\",\n        \"engine.scraper.is_idle()\",\n    ]\n    spider_tests = [\n        \"engine.spider_is_idle(spider)\",\n        \"engine.slot.closing\",\n        \"len(engine.slot.inprogress)\",\n        \"len(engine.slot.scheduler.dqs or [])\",\n        \"len(engine.slot.scheduler.mqs)\",\n        \"len(engine.scraper.slot.queue)\",\n        \"len(engine.scraper.slot.active)\",\n        \"engine.scraper.slot.active_size\",\n        \"engine.scraper.slot.itemproc_size\",\n        \"engine.scraper.slot.needs_backout()\",\n    ]\n\n    status = {'global': [], 'spiders': {}}\n    for test in global_tests:\n        try:\n            status['global'] += [(test, eval(test))]\n        except Exception as e:\n            status['global'] += [(test, \"%s (exception)\" % type(e).__name__)]\n    for spider in engine.slots.keys():\n        x = []\n        for test in spider_tests:\n            try:\n                x += [(test, eval(test))]\n            except Exception as e:\n                x += [(test, \"%s (exception)\" % type(e).__name__)]\n            status['spiders'][spider] = x\n    return status\n\ndef format_engine_status(engine=None):\n    status = get_engine_status(engine)\n    s = \"Execution engine status\\n\\n\"\n    for test, result in status['global']:\n        s += \"%-47s : %s\\n\" % (test, result)\n    s += \"\\n\"\n    for spider, tests in status['spiders'].items():\n        s += \"Spider: %s\\n\" % spider\n        for test, result in tests:\n            s += \"  %-50s : %s\\n\" % (test, result)\n    return s\n\ndef print_engine_status(engine):\n    print(format_engine_status(engine))\n\n", "path": "scrapy/utils/engine.py"}], "after_files": [{"content": "\"\"\"Some debugging functions for working with the Scrapy engine\"\"\"\n\nfrom __future__ import print_function\nfrom time import time # used in global tests code\n\ndef get_engine_status(engine):\n    \"\"\"Return a report of the current engine status\"\"\"\n    tests = [\n        \"time()-engine.start_time\",\n        \"engine.has_capacity()\",\n        \"len(engine.downloader.active)\",\n        \"engine.scraper.is_idle()\",\n        \"engine.spider.name\",\n        \"engine.spider_is_idle(engine.spider)\",\n        \"engine.slot.closing\",\n        \"len(engine.slot.inprogress)\",\n        \"len(engine.slot.scheduler.dqs or [])\",\n        \"len(engine.slot.scheduler.mqs)\",\n        \"len(engine.scraper.slot.queue)\",\n        \"len(engine.scraper.slot.active)\",\n        \"engine.scraper.slot.active_size\",\n        \"engine.scraper.slot.itemproc_size\",\n        \"engine.scraper.slot.needs_backout()\",\n    ]\n\n    checks = []\n    for test in tests:\n        try:\n            checks += [(test, eval(test))]\n        except Exception as e:\n            checks += [(test, \"%s (exception)\" % type(e).__name__)]\n\n    return checks\n\ndef format_engine_status(engine=None):\n    checks = get_engine_status(engine)\n    s = \"Execution engine status\\n\\n\"\n    for test, result in checks:\n        s += \"%-47s : %s\\n\" % (test, result)\n    s += \"\\n\"\n\n    return s\n\ndef print_engine_status(engine):\n    print(format_engine_status(engine))\n", "path": "scrapy/utils/engine.py"}]}