Error while installing lua socket - sockets

I am using lua 5.1 in a linux system.I installed the luasocket 2.0.2 using this manual.But when i execute the below code of the file test.lua
socket = require("socket")
print(socket._VERSION)
I get the following errors :
lua: ./usr/local/share/lua/5.1/socket.lua:14: loop or previous error loading module 'socket'
stack traceback:
[C]: in function 'require'
./usr/local/share/lua/5.1/socket.lua:14: in main chunk
[C]: in function 'require'
test.lua:1: in main chunk
[C]: ?
But i have included the environmental variable as below:
LUA_PATH=/usr/local/share/lua/5.1/?.lua;?.lua
LUA_CPATH=/usr/local/lib/lua/5.1/?.so;?.so

You usually get this error when you have a loop in your require calls, for example, when you do require "socket" and from that module you do require "socket" again, before the first require call is finished.
Check line 14 in socket.lua file. It should probably have something like local socket = require("socket.core") (and not require("socket")). To check if the issue is with loading socket.core, try executing require "socket.core" in your own script as it may give you a better error message.

Related

Eclipse / PyDev Stop button not working with OSError: [WinError 6] The handle is invalid error

I have the following Eclipse version on Windows 10:
Version: 2020-09 (4.17.0)
Build id: 20200910-1200
I am using PyDev along with it.
In my code I am using selenium to make a number of url calls (web scraping). When it happens that a particular url is not present or at least not present in the way most of the urls I am reading are, I get the following error:
Traceback (most recent call last):
File "C:\Users\foobar\eclipse-workspace\WeatherUndergroundUnderground\historical\BWI_Fetch.py", line 44, in <module>
main(city, month_date, start_year, end_year)
File "C:\Users\foobar\eclipse-workspace\WeatherUndergroundUnderground\historical\BWI_Fetch.py", line 22, in main
driver.get(city_url);
File "C:\Users\foobar\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get
self.execute(Command.GET, {'url': url})
File "C:\Users\foobar\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\foobar\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Reached error page: about:neterror
Exception ignored in: <function Popen.__del__ at 0x0000019267429F70>
Traceback (most recent call last):
File "C:\Users\foobar\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 945, in __del__
self._internal_poll(_deadstate=_maxsize)
File "C:\Users\foobar\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 1344, in _internal_poll
if _WaitForSingleObject(self._handle, 0) == _WAIT_OBJECT_0:
OSError: [WinError 6] The handle is invalid
When I get this particular error, eclipse is still running and pushing the red stop button does not work to end the program. I can usually use the red stop button for just about any other python program I have written, but this code/error seems to hang things. How can I end the process from within the Eclipse application?
The error in the stack trace is not really related to PyDev, so, the stack trace error is only really fixable in Selenium/Python (the error says that it's trying to access a process which is already dead on the __del__).
Now, related to the reason why PyDev wasn't able to kill it, I think that you probably have some process which spawned a subprocess and is not reachable anymore because the parent process died and thus it's not possible to create a tree to kill that process from the initial process launched in PyDev.
The actual code which does this in PyDev is: https://github.com/fabioz/winp/blob/master/native/winp.cpp#L208
I think that it should be possible to use the windows api to create a JobObject and then AssignProcessToJobObject and on kill also kill the JobObject so that it kills all associated processes so that things are setup in a way that that this doesn't happen, but this isn't currently done.
As a note, usually I have an alias for: taskkill /im python.exe /f (which will kill all the python.exe processes running in the machine) and it's what I usually use in such cases, so, if something like that happens I just kill all the python.exe processes in the machine.
Although note that if you spawned some other process... say, chrome.exe -- in that process tree, that process must also be killed for the initial shell that launched python to be really disposed.
This error message...
Exception ignored in: <function Popen.__del__ at 0x0000019267429F70>
...implies that the builtins module was destroyed before running __del__ in process of garbage collecting.
Hence PyDev is no more able to communicate with the relevant python modules. As a result Stop button isn't functioning and raises the error:
OSError: [WinError 6] The handle is invalid

"socket.core" is not a valid Win32 application

After Reading this, downloading the x64 binary of socket and replacing them in the lua "clibs" directory, with no positive results, I would like some help on resolving the following error that i'm receiving from eclipse:
Exception in thread "main" com.naef.jnlua.LuaRuntimeException: error loading module 'socket.core' from file 'C:\Program Files (x86)\Lua\5.1\clibs\socket\core.dll':
%1 is not a valid Win32 application.
at com.naef.jnlua.LuaState.lua_pcall(Native Method)
at com.naef.jnlua.LuaState.call(LuaState.java:555)
at org.eclipse.ldt.support.lua51.internal.interpreter.JNLua51Launcher.run(JNLua51Launcher.java:128)
at org.eclipse.ldt.support.lua51.internal.interpreter.JNLua51Launcher.main(JNLua51Launcher.java:143)
This is my enviorioment:
Windows 10 x64;
Lua 5.3;
LUA_PATH is defined corretly;
LUA_CPATH is defined corretly;
Here is my code:
-- Requires
local socket = require 'socket'
-- Settings
host = "localhost"
port = 8384;
-- Program Start
print("Program Start")
-- Functions
local function main()
client = socket.connect(host, port)
client:send("test!")
while true do
s, status, partial = client:receive(1024)
print(s or partial)
if status == "closed" then
break
end
end
client:close()
end
main()
From the file path of your Lua installation (C:\Program Files (x86)\Lua\5.1\clibs\socket\core.dll), it looks like you have installed a 32-bit version of Lua, and are trying to load a 64-bit DLL with it. This won't work; the two architectures cannot be mixed in one process.
Either download the 32-bit version of the socket module or the 64-bit version of the Lua interpreter.

getting error when running resty-mongol in Lua through nginx

I am getting error when trying to running resty-mongol in Lua
through nginx. The err is " attempt to index global 'bit' (a nil
value)". My environment has
https://github.com/openresty/lua-nginx-module/releases/tag/v0.10.6 -
build with nginx 1.10.1 version.
Entry thread aborted: runtime error:
...ules/lua-resty-mongol/lib/resty/mongol/object_id.lua:56: attempt to
index global 'bit' (a nil value) stack traceback: coroutine 0:
...ules/lua-resty-mongol/lib/resty/mongol/object_id.lua:56: in main
chunk [C]: in function 'require'
...e/modules/lua-resty-mongol/lib/resty/mongol/bson.lua:25: in main
chunk [C]: in function 'require'
.../modules/lua-resty-mongol/lib/resty/mongol/colmt.lua:20: in main
chunk [C]: in function 'require'
...e/modules/lua-resty-mongol/lib/resty/mongol/dbmt.lua:9: in main
chunk [C]: in function 'require'enter code here
...e/modules/lua-resty-mongol/lib/resty/mongol/init.lua:14: in main
chunk.
And after a reboot i am getting on the line
mongo:new() [string "mongo:new()"]:1: attempt to call method 'new' (a
nil value)
I started getting this error all of a sudden and now it fails
everytime. The faliure is at the load module line within my code -
require "resty.mongol" line. what possibly have gone wrong. Has
anybody faced it yet?

Why do I get "./gettext.so: undefined symbol: PL_thr_key" when I try to use gettext in Lua?

I want to use the gettext library with Lua, but I get an undefined symbol error when I try to load it:
require('gettext')
error loading module 'gettext' from file './gettext.so':
./gettext.so: undefined symbol: PL_thr_key
stack traceback:
[C]: in ?
[C]: in function 'require'
stdin:1: in main chunk
[C]: in ?
PL_thr_key is defined in perlapi.h, so this appears to be related to Perl.
The error comes from a module compiled against threaded Perl while your Perl installation is not threaded. Try to switch the version of Perl you're using.

Error on websocket when try to use Ipython notebook in emacs

Got some error message in buffer Warning when try to evaluate my code
Error (websocket): in callback `on-open': Cannot send message to a closed websocket: cl-struct-websocket-frame, text, "{\"header\":{\"msg_id\":\"14735853-0ed2-4ef4-8f5a-312a198dd251\", \"username\":\"username\"\, \"session\":\"ab484abf-d4e6-4f83-2c2-de1b65264780\", \"msg_type\":\"execute_request\"}, \"metadata\":{}, \"content\":{\"code\":\"__import__('sys').stdout.write(__import__('os').getcwd())\", \"silent\":true, \\"user_variables\":[], \"user_expressions\":{}, \"allow_stdin\":false}, \"parent_header\":{}}", nil, t
Error (websocket): in callback `on-open': Wrong type argument: arrayp, nil
Error (websocket): in callback `on-close': Wrong type argument: arrayp, nil
And on the ipython server side I saw this message
2014-03-05 23:24:40.760 [NotebookApp] WARNING | Cross Origin WebSocket Attempt.
2014-03-05 23:24:40.761 [tornado.application] ERROR | Uncaught exception in /kernels/2691bbe3-ce95-439b-a9ce-97ec52c80988/shell
Traceback (most recent call last):
File "/home/haroldwu/Python-test/lib/python3.3/site-packages/tornado/websocket.py", line 322, in wrapper
return callback(*args, **kwargs)
File "/home/haroldwu/Python-test/lib/python3.3/site-packages/IPython/html/base/zmqhandlers.py", line 114, in open
raise web.HTTPError(404)
tornado.web.HTTPError: HTTP 404: Not Found
What I have done:
Upgrade all package of my python virtualenv and global environment
Upgrade all system package (Archlinux latest 64-bit)
Upgrade all emacs package
Search the web (but found no useful result)
Ipython notebook worked on my emacs weeks ago, but somehow it dosen't work now...
I have no experience on tornado.
Thanks for your help!!! :)
I'd guess that emacs is not sending the Origin header which is checked by the Notebook WS code. See my comment https://github.com/ipython/ipython/issues/5525 .
Quick workaround is to comment out the same origin check in your /home/haroldwu/Python-test/lib/python3.3/site-packages/IPython/html/base/zmqhandlers.py:114 .
You can always add logging of parsed_origin, origin and origin_header in same_origin() function in zmqhandlers.py and fix the emacs package accordingly.