title: Scrapy throws error ReactorNotRestartable when runnning on AWS Lambda
body: <p>I have deployed a scrapy project which crawls whenever an lambda api requests comes.</p>
  
  <p>It runs perfectly for the first api call but later on it fails and throws ReactorNotRestartable error.</p>
  
  <p>As far as I can understand the AWS Lambda ecosystem is not killing the process, hence reactor is still present in the memory.</p>
  
  <p>The lambda log error is as follows:</p>
  
  <pre><code>Traceback (most recent call last):
  File "/var/task/aws-lambda.py", line 42, in run_company_details_scrapy
  process.start()
  File "./lib/scrapy/crawler.py", line 280, in start
  reactor.run(installSignalHandlers=False)  # blocking call
  File "./lib/twisted/internet/base.py", line 1242, in run
  self.startRunning(installSignalHandlers=installSignalHandlers)
  File "./lib/twisted/internet/base.py", line 1222, in startRunning
  ReactorBase.startRunning(self)
  File "./lib/twisted/internet/base.py", line 730, in startRunning
  raise error.ReactorNotRestartable()
  ReactorNotRestartable
  </code></pre>
  
  <p>The lambda handler function is:</p>
  
  <pre><code>def run_company_details_scrapy(event, context):
     process = CrawlerProcess()
     process.crawl(CompanyDetailsSpidySpider)
     process.start()
  </code></pre>
  
  <p>I had a workaround by not stopping the reactor by inserting a flag in the start function</p>
  
  <pre><code>process.start(stop_after_crawl=False)
  </code></pre>
  
  <p>But the problem with this was that I had to wait until the lambda call timed out.</p>
  
  <p>Tried other solutions, but none of them seems to work.Can anyone guide me how to solve this problem.</p>