received signal exits program but does not call signal handler - python-3.x

Problem
After my program runs within the main thread, I send a signal.SIGINT signal to interrupt the program and cause an exit to occur. The program shuts down, however the signal handler is not called for some reason, I need the signal handler to call to run some cleanup code.
Background Info
Currently I'm running on:
- Windows 10
- Python 3.7.3 x64
I've tried sending multiple different signals such as SIGINT, SIGTERM and CTRL_C_EVENT from the builtin signals module. In all cases, the program flow is interrupted and the program exits, however the signal_handler is not called.
I'm aware that all signals are only received by the main function, so that is something I have tried to adhere to within the code.
Code
Where:
client = discordpy client object from the rewrite
init_sanic() = initialises the sanic web framework
class ForcedShutdown(Exception):
"""
Custom exception to be raised
"""
pass
def signal_handler(signal, frame):
print(f'signal received is {signal}')
raise ForcedShutdown
if(__name__ == '__main__'):
try:
signal.signal(signal.SIGINT, signal_handler)
client = DiscordBot()
bot_thread = Thread(target=lambda : client.run(setup_pars['CLIENT_TOKEN']))
api_thread = Thread(target=lambda : init_sanic())
threads = [api_thread, bot_thread]
for x in threads:
x.start()
while True:
time.sleep(100)
except (ForcedShutdown, SystemExit):
print('DO SHUTDOWN ACTIONS')
The output:
[2019-07-31 19:49:18 +0100] [11808] [DEBUG]
Sanic
Build Fast. Run Fast.
[2019-07-31 19:49:18 +0100] [11808] [INFO] Goin' Fast # http://0.0.0.0:8000
[2019-07-31 19:49:18 +0100] [11808] [WARNING] Sanic tried to use loop.add_signal_handler but it is not implemented on this platform.
[2019-07-31 19:49:18 +0100] [11808] [WARNING] Sanic tried to use loop.add_signal_handler but it is not implemented on this platform.
[2019-07-31 19:49:18 +0100] [11808] [INFO] Starting worker [11808]
Discord Bot Loaded
Code used to send the signal:
import os
import signal
os.kill(pid, signal.SIGINT)
Final output:
Process finished with exit code 2
Expected Output
While the code exits as expected, the outputs is:
[2019-07-31 19:49:18 +0100] [11808] [DEBUG]
Sanic
Build Fast. Run Fast.
[2019-07-31 19:49:18 +0100] [11808] [INFO] Goin' Fast # http://0.0.0.0:8000
[2019-07-31 19:49:18 +0100] [11808] [WARNING] Sanic tried to use loop.add_signal_handler but it is not implemented on this platform.
[2019-07-31 19:49:18 +0100] [11808] [WARNING] Sanic tried to use loop.add_signal_handler but it is not implemented on this platform.
[2019-07-31 19:49:18 +0100] [11808] [INFO] Starting worker [11808]
Discord Bot Loaded
Process finished with exit code 2
Whereas the expected final output is:
[2019-07-31 19:49:18 +0100] [11808] [DEBUG]
Sanic
Build Fast. Run Fast.
[2019-07-31 19:49:18 +0100] [11808] [INFO] Goin' Fast # http://0.0.0.0:8000
[2019-07-31 19:49:18 +0100] [11808] [WARNING] Sanic tried to use loop.add_signal_handler but it is not implemented on this platform.
[2019-07-31 19:49:18 +0100] [11808] [WARNING] Sanic tried to use loop.add_signal_handler but it is not implemented on this platform.
[2019-07-31 19:49:18 +0100] [11808] [INFO] Starting worker [11808]
Discord Bot Loaded
DO SHUTDOWN ACTIONS
Process finished with exit code 2
Thanks for any help!

Related

moveit package following instructions provided but faced error after running in ros 2

[robot_state_publisher-3] [INFO] [1672396573.523060458] [robot_state_publisher]: got segment link6
[robot_state_publisher-3] [INFO] [1672396573.523065047] [robot_state_publisher]: got segment world
[ERROR] [robot_state_publisher-3]: process[robot_state_publisher-3] failed to terminate '5' seconds after receiving 'SIGINT', escalating to 'SIGTERM'
[INFO] [robot_state_publisher-3]: sending signal 'SIGTERM' to process[robot_state_publisher-3]
[ERROR] [robot_state_publisher-3]: process has died [pid 87783, exit code -15, cmd '/opt/ros/foxy/lib/robot_state_publisher/robot_state_publisher --ros-args -r __node:=robot_state_publisher --params-file /tmp/launch_params_7xb9pf6_'].
I tried to use your moveit package following instructions provided but faced error after running
$ ros2 launch moveit_config_m1013 m1013.launch.py

Open a connexion-based REST service with gunicorn

I have a Flask service built with connexion. The service is initialized in a function create_app() that is defined in the script src/group/application/my_service/api/app.py :
# app.py
def create_app():
arguments = {"url": "0.0.0.0"}
app = connexion.App(__name__, options={"swagger_ui": True})
app.add_api("openapi-spec.yml", arguments=arguments, strict_validation=True)
app.run(port=8080, debug=True)
In src/group/application/my_service/__main__.py, I import create_app and execute it:
# __main__.py
from group.application.my_service.api.app import create_app
create_app()
With this in place, I can successfully open the service with python :
python -m src.group.application.my_service
I would like now to use gunicorn instead. I am trying the following command
gunicorn -w 1 -b 0.0.0.0:8080 'src.group.application.my_service.api.app:create_app()'
but I am getting the following error message :
[2021-05-19 11:55:32 +0200] [13275] [INFO] Starting gunicorn 20.1.0
[2021-05-19 11:55:32 +0200] [13275] [INFO] Listening at: http://0.0.0.0:8080 (13275)
[2021-05-19 11:55:32 +0200] [13275] [INFO] Using worker: sync
[2021-05-19 11:55:32 +0200] [13276] [INFO] Booting worker with pid: 13276
* Serving Flask app "src.group.application.my_service.api.app" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: on
2021-05-19 11:55:33,672 [CRITICAL] Traceback (most recent call last):
File "/Users/user/repo_name/src/group/application/my_service/api/app.py", line 39, in create_app
app.run(port=8080, debug=True)
File "/Users/user/venvs/venv/lib/python3.9/site-packages/connexion/apps/flask_app.py", line 96, in run
self.app.run(self.host, port=self.port, debug=self.debug, **options)
File "/Users/user/venvs/venv/lib/python3.9/site-packages/flask/app.py", line 990, in run
run_simple(host, port, self, **options)
File "/Users/user/venvs/venv/lib/python3.9/site-packages/werkzeug/serving.py", line 1030, in run_simple
s.bind(server_address)
OSError: [Errno 48] Address already in use
Failed to find application object: 'create_app()'
[2021-05-19 11:55:33 +0200] [13276] [INFO] Worker exiting (pid: 13276)
[2021-05-19 11:55:33 +0200] [13275] [INFO] Shutting down: Master
[2021-05-19 11:55:33 +0200] [13275] [INFO] Reason: App failed to load.
How can I successfully open the service with Gunicorn, and without having the warning message about the fact that I am in a development service (which is the root cause why I want to use gunicorn) ?
It turns out that the function creat_app() should return app instead of calling app.run()

Override Maven's download of a 3rd party software with a local copy?

I am running the 32-bit build of Ubuntu 18.04 and attempting to build a 32-bit Jenkins from the source.
It fails in the last stage (see below) because it cannot find a Linux x86 build of Nodejs. They don't make 32-bit versions for Linux anymore. I'm fine with that - I have downloaded the 14.15.4 Nodejs sources and built my own 32-bit version. How can I override the Jenkins maven build that is attempting to download a non-existent package directly from the Nodejs distribution site?
I have tried prepositioning my home-built node-14.15.4-linux-x86.tar.gz in the appropriate location, but the build is getting killed because the package does not exist on the website it is attempting to download from (404 - Not Found). If I could stop it trying to download or tell it to pull the .tar.gz package from the local filesystem, I think that should fix the problem. I haven't found anything online and maven configurations are completely foreign to me.
[INFO] Installing node version v14.15.4
[INFO] Downloading https://nodejs.org/dist/v14.15.4/node-v14.15.4-linux-x86.tar.gz to /home/scott/.m2/repository/com/github/eirslett/node/14.15.4/node-14.15.4-linux-x86.tar.gz
[INFO] No proxies configured
[INFO] No proxy was configured, downloading directly
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Jenkins main module 2.275-SNAPSHOT:
[INFO]
[INFO] Jenkins main module ................................ SUCCESS [ 4.868 s]
[INFO] Jenkins BOM ........................................ SUCCESS [ 0.156 s]
[INFO] Jenkins cli ........................................ SUCCESS [ 10.285 s]
[INFO] Jenkins core ....................................... SUCCESS [01:12 min]
[INFO] Jenkins war ........................................ FAILURE [ 4.536 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:35 min
[INFO] Finished at: 2021-01-08T00:47:30-06:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.11.0:install-node-and-yarn (install node and yarn) on project jenkins-war: Could not download Node.js: Got error code 404 from the server. -> [Help 1]

Deploy Python-Flask api in Azure

I have deployed Python-Flask API in Azure. Its working fine in development environment. It has following dependencies which is mentioned in a .txt file.
click==6.7
Flask==1.0.2
itsdangerous==0.24
Jinja2==2.10
MarkupSafe==1.0
Werkzeug==0.14.1
jsonpickle==1.0
pyodbc==4.0.25
I have an app.py class which has some function that contains some DB CURD operations. It also has a db.py which contain below code :
import pyodbc
cnxn = pyodbc.connect(cs)
But when I am navigating to https://kmsazapi.azurewebsites.net/ it is giving below error
:( Application Error. If you are the application administrator, you can access the diagnostic resources.
Please find the Application logs from Azure :
2019-01-19T16:30:46.743756546Z
2019-01-19T16:30:46.893500456Z Starting OpenBSD Secure Shell server: sshd.
2019-01-19T16:30:46.921319668Z Running python /usr/local/bin/entrypoint.py
2019-01-19T16:30:47.042444539Z executing:
2019-01-19T16:30:47.042628845Z python --version
2019-01-19T16:30:47.060630336Z Python 3.7.1
2019-01-19T16:30:47.060830442Z executing:
2019-01-19T16:30:47.060993448Z pip --version
2019-01-19T16:30:49.209547693Z pip 10.0.1 from /home/site/wwwroot/antenv/lib/python3.7/site-packages/pip (python 3.7)
2019-01-19T16:30:49.214266747Z found flask app
2019-01-19T16:30:49.219978635Z executing:
2019-01-19T16:30:49.219990835Z . antenv/bin/activate
2019-01-19T16:30:49.224706090Z
2019-01-19T16:30:49.224798193Z executing:
2019-01-19T16:30:49.224971698Z GUNICORN_CMD_ARGS="--bind=0.0.0.0 --timeout 600" gunicorn application:app
2019-01-19T16:30:50.183264018Z [2019-01-19 16:30:50 +0000] [36] [INFO] Starting gunicorn 19.9.0
2019-01-19T16:30:50.183984042Z [2019-01-19 16:30:50 +0000] [36] [INFO] Listening at: http://0.0.0.0:8000 (36)
2019-01-19T16:30:50.184216749Z [2019-01-19 16:30:50 +0000] [36] [INFO] Using worker: sync
2019-01-19T16:30:50.194083973Z [2019-01-19 16:30:50 +0000] [39] [INFO] Booting worker with pid: 39
2019-01-19T16:30:50.967282324Z [2019-01-19 16:30:50 +0000] [39] [ERROR] Exception in worker process
2019-01-19T16:30:50.967302024Z Traceback (most recent call last):
2019-01-19T16:30:50.967306124Z File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2019-01-19T16:30:50.967311525Z worker.init_process()
2019-01-19T16:30:50.967325625Z File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
2019-01-19T16:30:50.967329625Z self.load_wsgi()
2019-01-19T16:30:50.967332825Z File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
2019-01-19T16:30:50.967336425Z self.wsgi = self.app.wsgi()
2019-01-19T16:30:50.967347026Z File "/usr/local/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2019-01-19T16:30:50.967350926Z self.callable = self.load()
2019-01-19T16:30:50.967354226Z File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
2019-01-19T16:30:50.967357626Z return self.load_wsgiapp()
2019-01-19T16:30:50.967361026Z File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
2019-01-19T16:30:50.967364426Z return util.import_app(self.app_uri)
2019-01-19T16:30:50.967367726Z File "/usr/local/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app
2019-01-19T16:30:50.967371427Z import(module)
2019-01-19T16:30:50.967374727Z File "/home/site/wwwroot/application.py", line 7, in
2019-01-19T16:30:50.967378427Z import db
2019-01-19T16:30:50.967381627Z File "/home/site/wwwroot/db.py", line 1, in
2019-01-19T16:30:50.967385027Z import pyodbc
2019-01-19T16:30:50.967388327Z ImportError: libodbc.so.2: cannot open shared object file: No such file or directory
2019-01-19T16:30:50.967653236Z [2019-01-19 16:30:50 +0000] [39] [INFO] Worker exiting (pid: 39)
2019-01-19T16:30:51.050986468Z [2019-01-19 16:30:51 +0000] [36] [INFO] Shutting down: Master
2019-01-19T16:30:51.051229076Z [2019-01-19 16:30:51 +0000] [36] [INFO] Reason: Worker failed to boot.
2019-01-19T16:30:51.102156846Z
What I am missing ?
Update: 0115:
If you deploy the python app to web app for windows, you can install the python extension as below: Go to azure portal -> your app service -> Extensions -> Add -> choose extensions:
How do you deploy your flask app?
You can refer to the official doc for the deployment. I followed the doc, and can work well in azure with the site https://xxx.azurewebsites.net/home .
my code:
from flask import Flask
app = Flask(__name__)
#app.route("/home")
def home():
return "Hello World a nice day!"
after deploy to azure, the site works well:

Local functional tests start after more then 1 minute

I have the same tests, the same selenium-server-standalone (2.43.1) and chromedriver (2.10).
I have only functional tests (no unit tests).
My Chrome is at version 37. My OSX is at version 10.9.5. Java version is 1.7.0_51 (Java 7 update 67).
When I run tests a new Chrome instance is opened with an empty tab:
With intern 1.7.0 tests start in less then 10 seconds.
With intern 2.1.1 tests start in 55-60 seconds.
Selenium logs look like this (when run by intern 2.1.1):
01:26:50.195 INFO - Launching a standalone server
01:26:50.388 INFO - Java: Oracle Corporation 24.51-b03
01:26:50.388 INFO - OS: Mac OS X 10.9.5 x86_64
01:26:50.487 INFO - v2.43.1, with Core v2.43.1. Built from revision 5163bce
01:26:50.734 INFO - Default driver org.openqa.selenium.ie.InternetExplorerDriver registration is skipped: registration capabilities Capabilities [{platform=WINDOWS, ensureCleanSession=true, browserName=internet explorer, version=}] does not match with current platform: MAC
01:26:50.846 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
01:26:50.847 INFO - Version Jetty/5.1.x
01:26:50.850 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
01:26:50.851 INFO - Started HttpContext[/selenium-server,/selenium-server]
01:26:50.851 INFO - Started HttpContext[/,/]
01:26:56.063 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler#1f8f110d
01:26:56.064 INFO - Started HttpContext[/wd,/wd]
01:26:56.101 INFO - Started SocketListener on 0.0.0.0:4444
01:26:56.101 INFO - Started org.openqa.jetty.jetty.Server#71a9b093
01:27:24.536 INFO - Executing: [new session: Capabilities [{idle-timeout=60, browserName=chrome, name=tests/intern_local, selenium-version=2.43.1, chromeOptions={args=[test-type]}}]])
01:27:24.592 INFO - Creating a new session for Capabilities [{idle-timeout=60, browserName=chrome, name=tests/intern_local, selenium-version=2.43.1, chromeOptions={args=[test-type]}}]
Starting ChromeDriver (v2.10.267517) on port 32601
Only local connections are allowed.
01:27:26.447 INFO - Done: [new session: Capabilities [{idle-timeout=60, browserName=chrome, name=tests/intern_local, selenium-version=2.43.1, chromeOptions={args=[test-type]}}]]
01:27:26.465 INFO - Executing: [get: about:blank])
01:27:26.865 INFO - Done: [get: about:blank]
01:27:26.875 INFO - Executing: [get location context])
01:27:26.876 INFO - Executing: [take screenshot])
01:27:26.876 INFO - Executing: [get local storage size])
01:27:26.876 INFO - Executing: [doubleclick: no args])
01:27:26.878 INFO - Executing: [execute async script: arguments[0](true);, []])
01:27:27.109 INFO - Done: [take screenshot]
01:27:27.114 INFO - Executing: [Long press: null])
01:27:27.154 INFO - Done: [doubleclick: no args]
01:27:27.158 INFO - Executing: [get window size])
01:27:27.169 INFO - Done: [execute async script: arguments[0](true);, []]
01:27:27.169 WARN - Exception thrown
java.lang.UnsupportedOperationException: Underlying driver does not implement advanced user interactions yet.
at org.openqa.selenium.support.events.EventFiringWebDriver.getTouch(EventFiringWebDriver.java:311)
at org.openqa.selenium.remote.server.handler.interactions.touch.LongPressOnElement.call(LongPressOnElement.java:40)
at org.openqa.selenium.remote.server.handler.interactions.touch.LongPressOnElement.call(LongPressOnElement.java:1)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:169)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
01:27:27.189 WARN - Exception: Underlying driver does not implement advanced user interactions yet.
01:27:27.205 INFO - Done: [get window size]
01:27:27.212 INFO - Executing: [set window size])
01:27:27.323 INFO - Done: [set window size]
01:27:31.956 WARN - Exception thrown
org.openqa.selenium.WebDriverException: unknown error: Location must be set before it can be retrieved
(Session info: chrome=37.0.2062.124)
(Driver info: chromedriver=2.10.267517,platform=Mac OS X 10.9.5 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 3 milliseconds
Build info: version: '2.43.1', revision: '5163bce', time: '2014-09-10 16:27:33'
System info: host: 'N/A', ip: 'N/A', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.5', java.version: '1.7.0_51'
Session ID: 25d1fbe63300966edb133612003055d1
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=MAC, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome, chrome={userDataDir=/var/folders/zx/954mnbfn6s145t6d04g5nr5h0000gq/T/.org.chromium.Chromium.dGVeyG}, rotatable=false, locationContextEnabled=true, version=37.0.2062.124, takesHeapSnapshot=true, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, nativeEvents=true, webStorageEnabled=true, applicationCacheEnabled=false, takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:614)
at org.openqa.selenium.remote.RemoteExecuteMethod.execute(RemoteExecuteMethod.java:32)
at org.openqa.selenium.remote.html5.RemoteLocationContext.location(RemoteLocationContext.java:38)
at org.openqa.selenium.chrome.ChromeDriver.location(ChromeDriver.java:195)
at org.openqa.selenium.remote.server.handler.html5.GetLocationContext.call(GetLocationContext.java:31)
at org.openqa.selenium.remote.server.handler.html5.GetLocationContext.call(GetLocationContext.java:1)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:169)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
01:27:37.029 WARN - Exception thrown
org.openqa.selenium.WebDriverException: unknown error: Runtime.evaluate threw exception: SecurityError: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
(Session info: chrome=37.0.2062.124)
(Driver info: chromedriver=2.10.267517,platform=Mac OS X 10.9.5 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 8 milliseconds
Build info: version: '2.43.1', revision: '5163bce', time: '2014-09-10 16:27:33'
System info: host: 'N/A', ip: 'N/A', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.5', java.version: '1.7.0_51'
Session ID: 25d1fbe63300966edb133612003055d1
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=MAC, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome, chrome={userDataDir=/var/folders/zx/954mnbfn6s145t6d04g5nr5h0000gq/T/.org.chromium.Chromium.dGVeyG}, rotatable=false, locationContextEnabled=true, version=37.0.2062.124, takesHeapSnapshot=true, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, nativeEvents=true, webStorageEnabled=true, applicationCacheEnabled=false, takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:614)
at org.openqa.selenium.remote.RemoteExecuteMethod.execute(RemoteExecuteMethod.java:32)
at org.openqa.selenium.remote.html5.RemoteLocalStorage.size(RemoteLocalStorage.java:72)
at org.openqa.selenium.remote.server.handler.html5.GetLocalStorageSize.call(GetLocalStorageSize.java:30)
at org.openqa.selenium.remote.server.handler.html5.GetLocalStorageSize.call(GetLocalStorageSize.java:1)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:169)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
01:27:47.173 WARN - Exception: unknown error: Location must be set before it can be retrieved
(Session info: chrome=37.0.2062.124)
(Driver info: chromedriver=2.10.267517,platform=Mac OS X 10.9.5 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 3 milliseconds
Build info: version: '2.43.1', revision: '5163bce', time: '2014-09-10 16:27:33'
System info: host: 'N/A', ip: 'N/A', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.5', java.version: '1.7.0_51'
Session ID: 25d1fbe63300966edb133612003055d1
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=MAC, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome, chrome={userDataDir=/var/folders/zx/954mnbfn6s145t6d04g5nr5h0000gq/T/.org.chromium.Chromium.dGVeyG}, rotatable=false, locationContextEnabled=true, version=37.0.2062.124, takesHeapSnapshot=true, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, nativeEvents=true, webStorageEnabled=true, applicationCacheEnabled=false, takesScreenshot=true}]
01:27:57.321 WARN - Exception: unknown error: Runtime.evaluate threw exception: SecurityError: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
(Session info: chrome=37.0.2062.124)
(Driver info: chromedriver=2.10.267517,platform=Mac OS X 10.9.5 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 8 milliseconds
Build info: version: '2.43.1', revision: '5163bce', time: '2014-09-10 16:27:33'
System info: host: 'N/A', ip: 'N/A', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.5', java.version: '1.7.0_51'
Session ID: 25d1fbe63300966edb133612003055d1
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=MAC, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome, chrome={userDataDir=/var/folders/zx/954mnbfn6s145t6d04g5nr5h0000gq/T/.org.chromium.Chromium.dGVeyG}, rotatable=false, locationContextEnabled=true, version=37.0.2062.124, takesHeapSnapshot=true, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, nativeEvents=true, webStorageEnabled=true, applicationCacheEnabled=false, takesScreenshot=true}]
01:28:27.773 INFO - Executing: [get: data:text/html;charset=utf-8,%3C!DOCTYPE%20html%3E%3Ctitle%3Ea%3C%2Ftitle%3E])
01:28:27.794 INFO - Done: [get: data:text/html;charset=utf-8,%3C!DOCTYPE%20html%3E%3Ctitle%3Ea%3C%2Ftitle%3E]
01:28:27.799 INFO - Executing: [get title])
01:28:27.803 INFO - Done: [get title]
...
My intern configuration looks like:
define({
proxyPort: 9000,
proxyUrl: 'http://localhost:9000/',
capabilities: {
'selenium-version': '2.43.1'
},
environments: [
{ browserName: 'chrome'}
],
maxConcurrency: 3,
tunnel: 'NullTunnel',
loader: {},
suites: [],
functionalSuites: 'tests/all_functional',
reporters: ['console'],
excludeInstrumentation: /^tests\//
});
I tried to use Selenium 2.42.2 with chromedriver 2.10 and chromedriver 2.9 but the results are similar.
Update 1
The same problem persist with OSX 10.10, Java 1.7.0_51 (Java 7 update 71), chromedriver 2.11 and Chrome 38.0.2125.104.
Update 2
I started looking at why there is such a big delay between HttpContext and ServletHandler startup. Debug shows that New random session seed takes that long time (5 sec). It seems that all errors that take longer time have time that is multiple of 5 (5 sec, 10 sec and 25 sec).
On other Unix systems this problem was solved by replacing /dev/random by /dev/urandom but on OSX there should be no difference between them. I tried feeding /dev/random with data while selenium was running but it didn't help.
Running with sudo gives the same result.
Specifying -Djava.security.egd=file:///dev/urandom gives the same result.
Update 3
On a new machine problem disappeared. And as I have no more the old machine - the answer will remain a mystery.
The only thing that I think could be different between these machines is JDK.
I ran into this issue on macOS Sierra when using selenium-standalone-server 2.42.2 and chromedriver 2.25. I tried several version combinations of the two while using java version 1.8.0_91 to no avail.
The issue was resolved by reverting to a previous version of java, java version 1.8.0_45. Not the best solution, so I'm using http://www.jenv.be/ to go back and forth when I need to. This does not identify the issue's root cause but I hope this workaround helps someone, took me a while to find it.

Resources