scrapinghub/splash — pull request #96 by chekunkov (2014-05-14 15:16:25+00:00)
Title: Fix for ReactorNotRunning exception

Found this one in logs:

```
2014-05-14 10:23:02+0000 [-] maxrss exceeded 1239 MB, shutting down...
2014-05-14 10:23:02+0000 [splash.proxy_server.SplashProxyFactory] (TCP Port 8051 Closed)
2014-05-14 10:23:02+0000 [splash.proxy_server.SplashProxyFactory] Stopping factory
2014-05-14 10:23:02+0000 [twisted.manhole.telnet.ShellFactory] (TCP Port 5023 Closed)
2014-05-14 10:23:02+0000 [twisted.manhole.telnet.ShellFactory] Stopping factory
2014-05-14 10:23:02+0000 [twisted.web.server.Site] (TCP Port 8050 Closed)
2014-05-14 10:23:02+0000 [twisted.web.server.Site] Stopping factory
2014-05-14 10:23:04+0000 [stats] {"maxrss": 1354556, "load": [0.22, 0.36, 0.44], "fds": 39, "qsize": 0, "rendertime": 5.2751548290252686, "active": 9, "path": "/render.json", "args": {"console": ["1"], "script": ["1"], "url": ["https://www.google.com/shopping/express/#HomePlace:cat=469.2915.473.477.2779&s=0&c=24&mall=Manhattan"], "html": ["1"], "js_source": ["\nvar oldTimeout = setTimeout;\nwindow.setTimeout = function(callback, timeout) {\n return callback();\n};\n\nvar getProductUrl = function () {\n var anchors = document.querySelectorAll('div > a');\n for (var i=0; i li > div');\n for (var ipd=0; ipd a');\n for (var i=0; i li > div');\n for (var ipd=0; ipd ---
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/splash/server.py", line 131, in check_maxrss
reactor.stop()
File "/usr/lib/python2.7/dist-packages/twisted/internet/base.py", line 577, in stop
"Can't stop reactor that isn't running.")
twisted.internet.error.ReactorNotRunning: Can't stop reactor that isn't running.

```

Looks like reactor.stop() was called twice which caused error. Added `reactor.running` check to avoid this.